Compare commits

...
Author SHA1 Message Date
Sebastien Pouliot 313cb0f6be Do not assume AddressList[0] has the address the test wants, that's not always the case, and not what UdpClient should be testing 2013-06-20 15:46:55 -04:00
Michael Hutchinson 8f3522361b [man] document MONO_CAIRO_DEBUG_DISPOSE 2013-06-20 14:06:30 -04:00
Miguel de Icaza 60834f6475 Merge pull request #666 from mhutch/cairo-fix-3.0
Mono.Cairo improvements
2013-06-20 10:56:48 -07:00
Sebastien Pouliot 1065fe4e2b [ios] Ignore the WindowsIdentityTest.SerializeRoundTrip test on iOS (see #12789) 2013-06-20 09:32:35 -04:00
Mark Probst 9f19f605d3 [sgen] Fix a Clang warning. 2013-06-19 17:02:44 -07:00
Rodrigo Kumpera 731080c76b [sdb] Add a test case for returning the right error when a m2n frame has no information. 2013-06-19 19:42:30 -04:00
Michael Hutchinson 86b07679f7 [Mono.Cairo] Use getter methods for returning IDisposables
This makes it a bit clearer that the caller is responsible for
disposing IDisposable objects returned from any method.
2013-06-19 18:37:36 -04:00
Michael Hutchinson 7085bed36e [Mono.Cairo] Clean up Region's Dispose/ctor 2013-06-19 18:37:25 -04:00
Michael Hutchinson 0bb971d513 Make debug more robust 2013-06-19 18:37:14 -04:00
Mike Kestner 9ce4c0db33 Mono.Cairo: Add Region class for cairo_region_* API added in cairo 1.10
The Region type is needed for new API introduced by GDK 3.0.

This requires cairo 1.10 or above.
2013-06-19 18:37:03 -04:00
Bertrand Lorentz 16f4114159 Mono.Cairo: Re-order a few native methods and update API index URL 2013-06-19 18:36:54 -04:00
Bertrand Lorentz befd617058 Mono.Cairo: Fix names of native functions used in PSSurface
It seems cairo_ps_surface_begin_* functions never existed, they were
always named cairo_ps_surface_dsc_begin_*.

Conflicts:
	mcs/class/Mono.Cairo/Mono.Cairo/PSSurface.cs
2013-06-19 18:36:44 -04:00
Cameron White 461fd11d95 Mono.Cairo: Fix rectangles returned by StrokeExtents and FillExtents
The third and fourth parameters of the Rectangle constructor are width
and height, but cairo_stroke_extents and cairo_fill_extents give right
and bottom coordinates.

Signed-off-by: Bertrand Lorentz <[email protected]>

Conflicts:
	mcs/class/Mono.Cairo/Mono.Cairo/Context.cs
2013-06-19 18:36:34 -04:00
Michael Hutchinson d5b2ccb50f [Mono.Cairo] Put some classes in separate files 2013-06-19 18:36:22 -04:00
Michael Hutchinson 7fb3dc1e9f Introduce Mono.Cairo to the concept of reference ownership
Also:
  * improving naming consistency
  * obsolete old/broken stuff
  * clean up tabs/space mix

NOTE: this removes the wrapper caches for Pattern and Surface as
there was no reliable way to clear them.

Conflicts:
	mcs/class/Mono.Cairo/Mono.Cairo/Context.cs
2013-06-19 18:36:11 -04:00
Michael Hutchinson 0d1b8bed31 [Mono.Cairo] Add mechanism to debug missing Dispose calls
by setting a new MONO_CAIRO_DEBUG_DISPOSE env var
2013-06-19 18:36:00 -04:00
Michael Hutchinson abc2892889 [Mono.Cairo] Clean up dispose implementations 2013-06-19 18:35:47 -04:00
Rodrigo Kumpera eba22c4e18 [sdb] When a frame is missing it's context, report absent information instead of invalid frame.
* debugger-agent.c (frame_commands): When a thread is suspended in native code its top frame
	will be missing a context, so it's not possible to inspect it. Instead of reporting an invalid
	frame, it makes more sense to report unavailable data as this is the right clue for clients.
2013-06-19 18:05:28 -04:00
Rolf Bjarne Kvinge cf87ac832f Fix 64bit long alignment on Apple platforms when using Clang.
__alignof__ doesn't work properly with Clang (it returns 8 instead of 4)
in this case.
2013-06-19 00:19:02 +02:00
Zoltan Varga b39c8299da Fix the build. 2013-06-18 01:20:10 +02:00
Zoltan Varga 0b258fe3a2 Fetch TLS offsets from GOT slots when using AOT instead of embedding them in code, since the offsets can be different at runtime. Reorganize the OP_TLS_GET emission code. 2013-06-17 23:55:49 +02:00
Martin Baulig 691a961db7 Fix the .spec file. 2013-06-17 22:32:22 +02:00
Zoltan Varga ef5f374520 Unify the tail call handling code with the normal call handling code a bit. 2013-06-15 22:50:39 +02:00
52 changed files with 1823 additions and 1060 deletions

No files matched your search

+5
View File
@@ -906,6 +906,11 @@ evictions start happening. If evictions are too frequent this could impose
unnecessary overhead, which could be avoided by using this environment variable
to set up a higher cache size (or to lower memory requirements by decreasing it).
.TP
\fBMONO_CAIRO_DEBUG_DISPOSE\fR
If set, causes Mono.Cairo to collect stack traces when objects are allocated,
so that the finalization/Dispose warnings include information about the
instance's origin.
.TP
\fBMONO_CFG_DIR\fR
If set, this variable overrides the default system configuration directory
($PREFIX/etc). It's used to locate machine.config file.
@@ -3,9 +3,12 @@
../../build/common/Locale.cs
./Mono.Cairo/Antialias.cs
./Mono.Cairo/Cairo.cs
./Mono.Cairo/CairoDebug.cs
./Mono.Cairo/Color.cs
./Mono.Cairo/Content.cs
./Mono.Cairo/Context.cs
./Mono.Cairo/DirectFBSurface.cs
./Mono.Cairo/Distance.cs
./Mono.Cairo/Extend.cs
./Mono.Cairo/FillRule.cs
./Mono.Cairo/Filter.cs
@@ -32,9 +35,12 @@
./Mono.Cairo/Pattern.cs
./Mono.Cairo/PatternType.cs
./Mono.Cairo/PdfSurface.cs
./Mono.Cairo/Point.cs
./Mono.Cairo/PointD.cs
./Mono.Cairo/PSSurface.cs
./Mono.Cairo/RadialGradient.cs
./Mono.Cairo/Rectangle.cs
./Mono.Cairo/Region.cs
./Mono.Cairo/ScaledFont.cs
./Mono.Cairo/SolidPattern.cs
./Mono.Cairo/Status.cs
@@ -0,0 +1,79 @@
//
// CairoDebug.cs
//
// Author:
// Michael Hutchinson ([email protected])
//
// 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 (!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);
}
}
}
+75
View File
@@ -0,0 +1,75 @@
//
// Mono.Cairo.Context.cs
//
// Author:
// Duncan Mak ([email protected])
// Miguel de Icaza ([email protected])
// Hisham Mardam Bey ([email protected])
// Alp Toker ([email protected])
//
// (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; }
}
}
}
File diff suppressed because it is too large. Load diff
@@ -36,11 +36,8 @@ namespace Cairo {
}
public DirectFBSurface (IntPtr dfb, IntPtr dfb_surface)
: base (NativeMethods.cairo_directfb_surface_create (dfb, dfb_surface), true)
{
surface = NativeMethods.cairo_directfb_surface_create (dfb, dfb_surface);
lock (surfaces.SyncRoot) {
surfaces [surface] = this;
}
}
}
}
@@ -0,0 +1,58 @@
//
// Mono.Cairo.Context.cs
//
// Author:
// Duncan Mak ([email protected])
// Miguel de Icaza ([email protected])
// Hisham Mardam Bey ([email protected])
// Alp Toker ([email protected])
//
// (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; }
}
}
}
+21 -15
View File
@@ -38,42 +38,48 @@ namespace Cairo
{
IntPtr handle;
internal static FontFace Lookup (IntPtr handle)
internal static FontFace Lookup (IntPtr handle, bool owner)
{
if (handle == IntPtr.Zero)
return null;
NativeMethods.cairo_font_face_reference (handle);
return new FontFace (handle);
return new FontFace (handle, owner);
}
~FontFace ()
{
// Since Cairo is not thread safe, we can not unref the
// font_face here, the programmer must do this with Dispose
Console.Error.WriteLine ("Programmer forgot to call Dispose on the FontFace");
Dispose (false);
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (disposing)
NativeMethods.cairo_font_face_destroy (handle);
if (!disposing || CairoDebug.Enabled)
CairoDebug.OnDisposed<FontFace> (handle, disposing);
if (!disposing|| handle == IntPtr.Zero)
return;
NativeMethods.cairo_font_face_destroy (handle);
handle = IntPtr.Zero;
GC.SuppressFinalize (this);
}
// TODO: make non-public when all entry points are complete in binding
public FontFace (IntPtr handle)
[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 {
+13 -9
View File
@@ -33,11 +33,9 @@ namespace Cairo
public class FontOptions : IDisposable
{
IntPtr handle;
bool disposed;
public FontOptions ()
public FontOptions () : this (NativeMethods.cairo_font_options_create ())
{
handle = NativeMethods.cairo_font_options_create ();
}
~FontOptions ()
@@ -48,6 +46,8 @@ namespace Cairo
internal FontOptions (IntPtr handle)
{
this.handle = handle;
if (CairoDebug.Enabled)
CairoDebug.OnAllocated (handle);
}
public FontOptions Copy ()
@@ -55,6 +55,7 @@ namespace Cairo
return new FontOptions (NativeMethods.cairo_font_options_copy (handle));
}
[Obsolete ("Use Dispose()")]
public void Destroy ()
{
NativeMethods.cairo_font_options_destroy (handle);
@@ -66,13 +67,16 @@ namespace Cairo
GC.SuppressFinalize (this);
}
private void Dispose (bool disposing)
protected virtual void Dispose (bool disposing)
{
if (!disposed) {
Destroy ();
handle = IntPtr.Zero;
}
disposed = true;
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)
@@ -36,11 +36,8 @@ namespace Cairo {
}
public GlitzSurface (IntPtr glitz_surface)
: base (NativeMethods.cairo_glitz_surface_create (glitz_surface), true)
{
surface = NativeMethods.cairo_glitz_surface_create (glitz_surface);
lock (surfaces.SyncRoot) {
surfaces [surface] = this;
}
}
}
}
+11 -10
View File
@@ -1,4 +1,4 @@
//
//
// Mono.Cairo.Gradient.cs
//
// Author: Jordi Mas ([email protected])
@@ -14,10 +14,10 @@
// 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
@@ -30,13 +30,14 @@
using System;
namespace Cairo {
public class Gradient : Pattern
{
protected Gradient (IntPtr handle) : base (handle)
protected Gradient (IntPtr handle, bool owned) : base (handle, owned)
{
}
[Obsolete]
protected Gradient ()
{
}
@@ -44,20 +45,20 @@ namespace Cairo {
public int ColorStopCount {
get {
int cnt;
NativeMethods.cairo_pattern_get_color_stop_count (pattern, out cnt);
NativeMethods.cairo_pattern_get_color_stop_count (Handle, out cnt);
return cnt;
}
}
public Status AddColorStop (double offset, Cairo.Color c)
public Status AddColorStop (double offset, Color c)
{
NativeMethods.cairo_pattern_add_color_stop_rgba (pattern, offset, c.R, c.G, c.B, c.A);
NativeMethods.cairo_pattern_add_color_stop_rgba (Handle, offset, c.R, c.G, c.B, c.A);
return Status;
}
public Status AddColorStopRgb (double offset, Cairo.Color c)
public Status AddColorStopRgb (double offset, Color c)
{
NativeMethods.cairo_pattern_add_color_stop_rgb (pattern, offset, c.R, c.G, c.B);
NativeMethods.cairo_pattern_add_color_stop_rgb (Handle, offset, c.R, c.G, c.B);
return Status;
}
}
+23 -34
View File
@@ -19,10 +19,10 @@
// 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
@@ -37,60 +37,49 @@ using System.Runtime.InteropServices;
namespace Cairo {
public class ImageSurface : Surface
{
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)
{
surface = NativeMethods.cairo_image_surface_create (format, width, height);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
[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 (ref byte[] data, Cairo.Format format, int width, int height, int stride)
: this (data, format, width, height, stride)
{
}
public ImageSurface (byte[] data, Cairo.Format format, int width, int height, int 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)
{
surface = NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public ImageSurface (IntPtr data, Cairo.Format format, int width, int height, int stride)
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)
{
surface = NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public ImageSurface (string filename)
: base (NativeMethods.cairo_image_surface_create_from_png (filename), true)
{
surface = NativeMethods.cairo_image_surface_create_from_png (filename);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public int Width {
get { return NativeMethods.cairo_image_surface_get_width (surface); }
get { return NativeMethods.cairo_image_surface_get_width (Handle); }
}
public int Height {
get { return NativeMethods.cairo_image_surface_get_height (surface); }
get { return NativeMethods.cairo_image_surface_get_height (Handle); }
}
public byte[] Data {
get {
IntPtr ptr = NativeMethods.cairo_image_surface_get_data (surface);
IntPtr ptr = NativeMethods.cairo_image_surface_get_data (Handle);
int length = Height * Stride;
byte[] data = new byte[length];
Marshal.Copy (ptr, data, 0, length);
@@ -100,16 +89,16 @@ namespace Cairo {
public IntPtr DataPtr {
get {
return NativeMethods.cairo_image_surface_get_data (surface);
return NativeMethods.cairo_image_surface_get_data (Handle);
}
}
public Format Format {
get { return NativeMethods.cairo_image_surface_get_format (surface); }
get { return NativeMethods.cairo_image_surface_get_format (Handle); }
}
public int Stride {
get { return NativeMethods.cairo_image_surface_get_stride (surface); }
get { return NativeMethods.cairo_image_surface_get_stride (Handle); }
}
}
}
@@ -1,4 +1,4 @@
//
//
// Mono.Cairo.LinearGradient.cs
//
// Author: Jordi Mas ([email protected])
@@ -14,10 +14,10 @@
// 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
@@ -30,31 +30,30 @@
using System;
namespace Cairo {
public class LinearGradient : Gradient
{
internal LinearGradient (IntPtr handle) : base (handle)
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)
{
pattern = NativeMethods.cairo_pattern_create_linear (x0, y0, x1, y1);
}
public PointD[] LinearPoints {
get {
get {
double x0, y0, x1, y1;
PointD[] points = new PointD [2];
NativeMethods.cairo_pattern_get_linear_points (pattern, out x0, out y0, out x1, out y1);
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;
}
}
}
}
}
}
+68 -68
View File
@@ -18,10 +18,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -36,110 +36,110 @@ using System.Runtime.InteropServices;
namespace Cairo {
[StructLayout(LayoutKind.Sequential)]
public class Matrix : ICloneable
{
[StructLayout(LayoutKind.Sequential)]
public class Matrix : ICloneable
{
public double Xx;
public double Yx;
public double Xy;
public double Xy;
public double Yy;
public double X0;
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 ()
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 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)
{
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_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)
{
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 ()
{
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 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 ()
@@ -148,7 +148,7 @@ namespace Cairo {
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 &&
@@ -158,14 +158,14 @@ namespace Cairo {
lhs.X0 == rhs.X0 &&
lhs.Y0 == rhs.Y0 );
}
public static bool operator != (Matrix lhs, Matrix rhs)
{
return !(lhs==rhs);
return !(lhs==rhs);
}
public override bool Equals(object o)
{
if (! (o is Matrix))
@@ -173,7 +173,7 @@ namespace Cairo {
else
return (this == (Matrix) o);
}
public override int GetHashCode()
{
return (int)this.Xx ^ (int)this.Xx>>32 ^
@@ -183,11 +183,11 @@ namespace Cairo {
(int)this.X0 ^ (int)this.X0>>32 ^
(int)this.Y0 ^ (int)this.Y0>>32;
}
public object Clone()
{
return this.MemberwiseClone ();
}
}
}
}
@@ -36,8 +36,8 @@ using System.Runtime.InteropServices;
namespace Cairo
{
// sort these so it is easier to find what is missing
// http://www.cairographics.org/manual/ix01.html
// 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
{
@@ -86,9 +86,6 @@ namespace Cairo
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern IntPtr cairo_create (IntPtr target);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern uint cairo_get_reference_count (IntPtr surface);
[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);
@@ -240,6 +237,9 @@ namespace Cairo
[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);
@@ -292,9 +292,6 @@ namespace Cairo
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern int cairo_image_surface_get_width (IntPtr surface);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
internal static extern uint cairo_surface_get_reference_count (IntPtr surface);
[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.U1)]
internal static extern bool cairo_in_fill (IntPtr cr, double x, double y);
@@ -453,10 +450,10 @@ namespace Cairo
//[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_begin_page_setup (IntPtr surface);
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_begin_setup (IntPtr surface);
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);
@@ -485,6 +482,75 @@ namespace Cairo
[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);
@@ -667,6 +733,9 @@ namespace Cairo
[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);
+5 -8
View File
@@ -37,31 +37,28 @@ namespace Cairo {
}
public PSSurface (string filename, double width, double height)
: base (NativeMethods.cairo_ps_surface_create (filename, width, height), true)
{
surface = NativeMethods.cairo_ps_surface_create (filename, width, height);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public void BeginPageSetup ()
{
NativeMethods.cairo_ps_surface_begin_page_setup (surface);
NativeMethods.cairo_ps_surface_dsc_begin_page_setup (Handle);
}
public void BeginSetup ()
{
NativeMethods.cairo_ps_surface_begin_setup (surface);
NativeMethods.cairo_ps_surface_dsc_begin_setup (Handle);
}
public void DscComment (string comment)
{
NativeMethods.cairo_ps_surface_dsc_comment (surface, comment);
NativeMethods.cairo_ps_surface_dsc_comment (Handle, comment);
}
public void SetSize (double width, double height)
{
NativeMethods.cairo_ps_surface_set_size (surface, width, height);
NativeMethods.cairo_ps_surface_set_size (Handle, width, height);
}
}
}
+20 -19
View File
@@ -15,10 +15,10 @@
// 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
@@ -34,13 +34,15 @@ using Cairo;
namespace Cairo {
public class Path : IDisposable
{
internal IntPtr handle = IntPtr.Zero;
public class Path : IDisposable
{
IntPtr handle = IntPtr.Zero;
internal Path (IntPtr handle)
{
this.handle = handle;
if (CairoDebug.Enabled)
CairoDebug.OnAllocated (handle);
}
~Path ()
@@ -48,25 +50,24 @@ namespace Cairo {
Dispose (false);
}
public IntPtr Handle { get { return handle; } }
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (!disposing){
Console.Error.WriteLine ("Cairo.Context: called from finalization thread, programmer is missing a call to Dispose");
return;
}
if (handle == IntPtr.Zero)
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);
NativeMethods.cairo_path_destroy (handle);
handle = IntPtr.Zero;
}
}
}
}
}
+73 -65
View File
@@ -1,4 +1,4 @@
//
//
// Mono.Cairo.Pattern.cs
//
// Author: Jordi Mas ([email protected])
@@ -32,116 +32,124 @@ using System.Collections;
namespace Cairo {
public class Pattern : IDisposable
{
protected IntPtr pattern = IntPtr.Zero;
public class Pattern : IDisposable
{
[Obsolete]
protected IntPtr pattern = IntPtr.Zero;
internal static Pattern Lookup (IntPtr pattern)
public static Pattern Lookup (IntPtr pattern, bool owner)
{
if (pattern == IntPtr.Zero)
return null;
object x = patterns [pattern];
if (x != null)
return (Pattern) x;
PatternType pt = NativeMethods.cairo_pattern_get_type (pattern);
switch (pt) {
case PatternType.Solid:
return new SolidPattern (pattern);
return new SolidPattern (pattern, owner);
case PatternType.Surface:
return new SurfacePattern (pattern);
return new SurfacePattern (pattern, owner);
case PatternType.Linear:
return new LinearGradient (pattern);
return new LinearGradient (pattern, owner);
case PatternType.Radial:
return new RadialGradient (pattern);
return new RadialGradient (pattern, owner);
default:
return new Pattern (pattern);
return new Pattern (pattern, owner);
}
}
protected Pattern ()
{
}
static Hashtable patterns = new Hashtable ();
internal Pattern (IntPtr ptr)
[Obsolete]
protected Pattern ()
{
lock (patterns){
patterns [ptr] = this;
}
pattern = ptr;
}
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)
{
pattern = NativeMethods.cairo_pattern_create_for_surface (surface.Handle);
}
[Obsolete ("Use the SurfacePattern constructor")]
public Pattern (Surface surface)
: this ( NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
{
}
protected void Reference ()
{
NativeMethods.cairo_pattern_reference (pattern);
}
[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)
Destroy ();
GC.SuppressFinalize (this);
if (!disposing || CairoDebug.Enabled)
CairoDebug.OnDisposed<Pattern> (Handle, disposing);
if (!disposing|| Handle == IntPtr.Zero)
return;
NativeMethods.cairo_pattern_destroy (Handle);
Handle = IntPtr.Zero;
}
public void Destroy ()
{
if (pattern != IntPtr.Zero){
NativeMethods.cairo_pattern_destroy (pattern);
pattern = IntPtr.Zero;
}
lock (patterns){
patterns.Remove (this);
}
}
[Obsolete ("Use Dispose()")]
public void Destroy ()
{
NativeMethods.cairo_pattern_destroy (pattern);
}
public Status Status
{
get { return NativeMethods.cairo_pattern_status (pattern); }
get { return NativeMethods.cairo_pattern_status (Handle); }
}
public Extend Extend
{
get { return NativeMethods.cairo_pattern_get_extend (pattern); }
set { NativeMethods.cairo_pattern_set_extend (pattern, value); }
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 (pattern, value);
public Matrix Matrix {
set {
NativeMethods.cairo_pattern_set_matrix (Handle, value);
}
get {
get {
Matrix m = new Matrix ();
NativeMethods.cairo_pattern_get_matrix (pattern, m);
NativeMethods.cairo_pattern_get_matrix (Handle, m);
return m;
}
}
}
}
public IntPtr Pointer {
get { return pattern; }
}
#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 (pattern); }
get { return NativeMethods.cairo_pattern_get_type (Handle); }
}
}
}
}
@@ -37,16 +37,13 @@ namespace Cairo {
}
public PdfSurface (string filename, double width, double height)
: base (NativeMethods.cairo_pdf_surface_create (filename, width, height), true)
{
surface = NativeMethods.cairo_pdf_surface_create (filename, width, height);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public void SetSize (double width, double height)
{
NativeMethods.cairo_pdf_surface_set_size (surface, width, height);
NativeMethods.cairo_pdf_surface_set_size (Handle, width, height);
}
}
}
+57
View File
@@ -0,0 +1,57 @@
//
// Mono.Cairo.Context.cs
//
// Author:
// Duncan Mak ([email protected])
// Miguel de Icaza ([email protected])
// Hisham Mardam Bey ([email protected])
// Alp Toker ([email protected])
//
// (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; }
}
}
}
+58
View File
@@ -0,0 +1,58 @@
//
// Mono.Cairo.Context.cs
//
// Author:
// Duncan Mak ([email protected])
// Miguel de Icaza ([email protected])
// Hisham Mardam Bey ([email protected])
// Alp Toker ([email protected])
//
// (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; }
}
}
}
@@ -1,4 +1,4 @@
//
//
// Mono.Cairo.Pattern.cs
//
// Author: Jordi Mas ([email protected])
@@ -14,10 +14,10 @@
// 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
@@ -30,16 +30,16 @@
using System;
namespace Cairo {
public class RadialGradient : Gradient
{
internal RadialGradient (IntPtr handle) : base (handle)
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)
{
pattern = NativeMethods.cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1);
}
}
}
+196
View File
@@ -0,0 +1,196 @@
// 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);
}
}
}
+31 -22
View File
@@ -32,14 +32,18 @@ namespace Cairo {
{
protected IntPtr handle = IntPtr.Zero;
internal ScaledFont (IntPtr handle)
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)
{
handle = NativeMethods.cairo_scaled_font_create (fontFace.Handle, matrix, ctm, options.Handle);
}
~ScaledFont ()
@@ -47,19 +51,19 @@ namespace Cairo {
Dispose (false);
}
public IntPtr Handle {
get {
return handle;
}
}
public IntPtr Handle {
get {
return handle;
}
}
public FontExtents FontExtents {
get {
FontExtents extents;
NativeMethods.cairo_scaled_font_extents (handle, out extents);
return extents;
}
}
get {
FontExtents extents;
NativeMethods.cairo_scaled_font_extents (handle, out extents);
return extents;
}
}
public Matrix FontMatrix {
get {
@@ -99,16 +103,21 @@ namespace Cairo {
protected virtual void Dispose (bool disposing)
{
if (disposing) {
NativeMethods.cairo_scaled_font_destroy (handle);
handle = IntPtr.Zero;
}
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);
}
protected void Reference ()
{
NativeMethods.cairo_scaled_font_reference (handle);
}
}
}
+16 -17
View File
@@ -1,4 +1,4 @@
//
//
// Mono.Cairo.Pattern.cs
//
// Author: Jordi Mas ([email protected])
@@ -14,10 +14,10 @@
// 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
@@ -30,44 +30,43 @@
using System;
namespace Cairo {
public class SolidPattern : Pattern
{
internal SolidPattern (IntPtr handle) : base (handle)
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)
{
pattern = NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A);
}
public SolidPattern (double r, double g, double b)
: base (NativeMethods.cairo_pattern_create_rgb (r, g, b), true)
{
pattern = NativeMethods.cairo_pattern_create_rgb (r, g, b);
}
public SolidPattern (double r, double g, double b, double a)
: base (NativeMethods.cairo_pattern_create_rgba (r, g, b, a), true)
{
NativeMethods.cairo_pattern_create_rgba (r, g, b, a);
}
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)
{
if (solid)
pattern = NativeMethods.cairo_pattern_create_rgb (color.R, color.G, color.B);
else
pattern = NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A);
}
public Color Color {
get {
get {
double red, green, blue, alpha;
NativeMethods.cairo_pattern_get_rgba (pattern, out red, out green, out blue, out alpha);
NativeMethods.cairo_pattern_get_rgba (Handle, out red, out green, out blue, out alpha);
return new Color (red, green, blue, alpha);
}
}
}
}
}
}
+91 -97
View File
@@ -20,10 +20,10 @@
// 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
@@ -38,94 +38,88 @@ using System.Collections;
namespace Cairo {
public class Surface : IDisposable
{
public class Surface : IDisposable
{
[Obsolete]
protected static Hashtable surfaces = new Hashtable ();
internal IntPtr surface = IntPtr.Zero;
IntPtr handle = IntPtr.Zero;
[Obsolete]
protected Surface()
{
}
protected Surface (IntPtr ptr, bool owns)
{
surface = ptr;
lock (surfaces.SyncRoot){
surfaces [ptr] = this;
}
if (!owns)
NativeMethods.cairo_surface_reference (ptr);
}
static internal Surface LookupExternalSurface (IntPtr p)
[Obsolete]
protected Surface (IntPtr ptr) : this (ptr, true)
{
lock (surfaces.SyncRoot){
object o = surfaces [p];
if (o == null){
return new Surface (p, false);
}
return (Surface) o;
}
}
}
static internal Surface LookupSurface (IntPtr surface)
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, true);
return new ImageSurface (surface, owned);
case SurfaceType.Xlib:
return new XlibSurface (surface, true);
return new XlibSurface (surface, owned);
case SurfaceType.Xcb:
return new XcbSurface (surface, true);
return new XcbSurface (surface, owned);
case SurfaceType.Glitz:
return new GlitzSurface (surface, true);
return new GlitzSurface (surface, owned);
case SurfaceType.Win32:
return new Win32Surface (surface, true);
return new Win32Surface (surface, owned);
case SurfaceType.Pdf:
return new PdfSurface (surface, true);
return new PdfSurface (surface, owned);
case SurfaceType.PS:
return new PSSurface (surface, true);
return new PSSurface (surface, owned);
case SurfaceType.DirectFB:
return new DirectFBSurface (surface, true);
return new DirectFBSurface (surface, owned);
case SurfaceType.Svg:
return new SvgSurface (surface, true);
return new SvgSurface (surface, owned);
default:
return Surface.LookupExternalSurface (surface);
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);
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);
}
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);
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);
}
return new Cairo.Surface (p, true);
}
~Surface ()
{
@@ -133,9 +127,9 @@ namespace Cairo {
}
//[Obsolete ("Use Context.SetSource() followed by Context.Paint()")]
public void Show (Context gr, double x, double y)
public void Show (Context gr, double x, double y)
{
NativeMethods.cairo_set_source_surface (gr.Handle, surface, x, y);
NativeMethods.cairo_set_source_surface (gr.Handle, handle, x, y);
NativeMethods.cairo_paint (gr.Handle);
}
@@ -147,55 +141,55 @@ namespace Cairo {
protected virtual void Dispose (bool disposing)
{
if (surface == IntPtr.Zero)
return;
lock (surfaces.SyncRoot)
surfaces.Remove (surface);
if (!disposing || CairoDebug.Enabled)
CairoDebug.OnDisposed<Surface> (handle, disposing);
NativeMethods.cairo_surface_destroy (surface);
surface = IntPtr.Zero;
if (!disposing|| handle == IntPtr.Zero)
return;
NativeMethods.cairo_surface_destroy (handle);
handle = IntPtr.Zero;
}
public Status Finish ()
{
NativeMethods.cairo_surface_finish (surface);
NativeMethods.cairo_surface_finish (handle);
return Status;
}
public void Flush ()
{
NativeMethods.cairo_surface_flush (surface);
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 surface;
public IntPtr Handle {
get {
return handle;
}
}
}
public PointD DeviceOffset {
get {
double x, y;
NativeMethods.cairo_surface_get_device_offset (surface, out x, out y);
NativeMethods.cairo_surface_get_device_offset (handle, out x, out y);
return new PointD (x, y);
}
set {
NativeMethods.cairo_surface_set_device_offset (surface, value.X, value.Y);
NativeMethods.cairo_surface_set_device_offset (handle, value.X, value.Y);
}
}
public void Destroy()
{
Dispose (true);
@@ -203,35 +197,35 @@ namespace Cairo {
public void SetFallbackResolution (double x, double y)
{
NativeMethods.cairo_surface_set_fallback_resolution (surface, x, y);
NativeMethods.cairo_surface_set_fallback_resolution (handle, x, y);
}
public void WriteToPng (string filename)
{
NativeMethods.cairo_surface_write_to_png (surface, filename);
NativeMethods.cairo_surface_write_to_png (handle, filename);
}
[Obsolete ("Use Handle instead.")]
public IntPtr Pointer {
get {
return surface;
public IntPtr Pointer {
get {
return handle;
}
}
}
public Status Status {
get { return NativeMethods.cairo_surface_status (surface); }
get { return NativeMethods.cairo_surface_status (handle); }
}
public Content Content {
get { return NativeMethods.cairo_surface_get_content (surface); }
get { return NativeMethods.cairo_surface_get_content (handle); }
}
public SurfaceType SurfaceType {
get { return NativeMethods.cairo_surface_get_type (surface); }
get { return NativeMethods.cairo_surface_get_type (handle); }
}
public uint ReferenceCount {
get { return NativeMethods.cairo_surface_get_reference_count (surface); }
get { return NativeMethods.cairo_surface_get_reference_count (handle); }
}
}
}
}
@@ -1,4 +1,4 @@
//
//
// Mono.Cairo.Pattern.cs
//
// Author: Jordi Mas ([email protected])
@@ -14,10 +14,10 @@
// 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
@@ -30,26 +30,27 @@
using System;
namespace Cairo {
public class SurfacePattern : Pattern
{
internal SurfacePattern (IntPtr handle) : base (handle)
internal SurfacePattern (IntPtr handle, bool owned) : base (handle, owned)
{
}
public SurfacePattern (Surface surface)
: base (NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
{
pattern = NativeMethods.cairo_pattern_create_for_surface (surface.Handle);
}
public Extend Extend {
set { NativeMethods.cairo_pattern_set_extend (pattern, value); }
get { return NativeMethods.cairo_pattern_get_extend (pattern); }
//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 (pattern, value); }
get { return NativeMethods.cairo_pattern_get_filter (pattern); }
set { NativeMethods.cairo_pattern_set_filter (Handle, value); }
get { return NativeMethods.cairo_pattern_get_filter (Handle); }
}
}
}
@@ -37,16 +37,13 @@ namespace Cairo {
}
public SvgSurface (string filename, double width, double height)
: base (NativeMethods.cairo_svg_surface_create (filename, width, height), true)
{
surface = NativeMethods.cairo_svg_surface_create (filename, width, height);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public void RestrictToVersion (SvgVersion version)
{
NativeMethods.cairo_svg_surface_restrict_to_version (surface, version);
NativeMethods.cairo_svg_surface_restrict_to_version (Handle, version);
}
}
}
@@ -37,12 +37,8 @@ namespace Cairo {
}
public Win32Surface (IntPtr hdc)
: base (NativeMethods.cairo_win32_surface_create (hdc), true)
{
surface = NativeMethods.cairo_win32_surface_create (hdc);
lock (surfaces.SyncRoot) {
surfaces [surface] = this;
}
}
}
}
@@ -36,24 +36,19 @@ namespace Cairo {
}
public XcbSurface (IntPtr connection, uint drawable, IntPtr visual, int width, int height)
: base (NativeMethods.cairo_xcb_surface_create (connection, drawable, visual, width, height), true)
{
surface = NativeMethods.cairo_xcb_surface_create (connection, drawable, visual, width, height);
lock (surfaces.SyncRoot) {
surfaces [surface] = this;
}
}
public static XcbSurface FromBitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height)
{
IntPtr ptr;
ptr = NativeMethods.cairo_xcb_surface_create_for_bitmap (connection, bitmap, screen, width, 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 (surface, width, height);
NativeMethods.cairo_xcb_surface_set_size (Handle, width, height);
}
}
}
+11 -16
View File
@@ -39,11 +39,8 @@ 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)
{
surface = NativeMethods.cairo_xlib_surface_create (display, drawable, visual, width, height);
lock (surfaces.SyncRoot){
surfaces [surface] = this;
}
}
public XlibSurface (IntPtr ptr, bool own) : base (ptr, own)
@@ -52,48 +49,46 @@ namespace Cairo {
public static XlibSurface FromBitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height)
{
IntPtr ptr;
ptr = NativeMethods.cairo_xlib_surface_create_for_bitmap (display, bitmap, screen, width, 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 (surface, drawable, width, height);
NativeMethods.cairo_xlib_surface_set_drawable (Handle, drawable, width, height);
}
public void SetSize (int width, int height)
{
NativeMethods.cairo_xlib_surface_set_size (surface, width, height);
NativeMethods.cairo_xlib_surface_set_size (Handle, width, height);
}
public int Depth {
get { return NativeMethods.cairo_xlib_surface_get_depth (surface); }
get { return NativeMethods.cairo_xlib_surface_get_depth (Handle); }
}
public IntPtr Display {
get { return NativeMethods.cairo_xlib_surface_get_display (surface); }
get { return NativeMethods.cairo_xlib_surface_get_display (Handle); }
}
public IntPtr Drawable {
get { return NativeMethods.cairo_xlib_surface_get_drawable (surface); }
get { return NativeMethods.cairo_xlib_surface_get_drawable (Handle); }
}
public int Height {
get { return NativeMethods.cairo_xlib_surface_get_height (surface); }
get { return NativeMethods.cairo_xlib_surface_get_height (Handle); }
}
public IntPtr Screen {
get { return NativeMethods.cairo_xlib_surface_get_screen (surface); }
get { return NativeMethods.cairo_xlib_surface_get_screen (Handle); }
}
public IntPtr Visual {
get { return NativeMethods.cairo_xlib_surface_get_visual (surface); }
get { return NativeMethods.cairo_xlib_surface_get_visual (Handle); }
}
public int Width {
get { return NativeMethods.cairo_xlib_surface_get_width (surface); }
get { return NativeMethods.cairo_xlib_surface_get_width (Handle); }
}
}
@@ -223,6 +223,12 @@ public class Tests : TestsBase
}
}
public static void wait_one ()
{
ManualResetEvent evt = new ManualResetEvent (false);
evt.WaitOne ();
}
public static int Main (String[] args) {
tls_i = 42;
@@ -241,6 +247,10 @@ public class Tests : TestsBase
unhandled_exception_user ();
return 0;
}
if (args.Length >0 && args [0] == "wait-one") {
wait_one ();
return 0;
}
breakpoints ();
single_stepping ();
arguments ();
+69 -1
View File
@@ -24,6 +24,7 @@ public class DebuggerTests
VirtualMachine vm;
MethodMirror entry_point;
StepEventRequest step_req;
bool forceExit;
void AssertThrows<ExType> (Action del) where ExType : Exception {
bool thrown = false;
@@ -47,7 +48,13 @@ public class DebuggerTests
return es [0];
}
void Start (string[] args) {
void Start (params string[] args) {
Start (false, args);
}
void Start (bool forceExit, params string[] args) {
this.forceExit = forceExit;
if (!listening) {
var pi = new Diag.ProcessStartInfo ();
@@ -155,6 +162,7 @@ public class DebuggerTests
[SetUp]
public void SetUp () {
ThreadMirror.NativeTransitions = false;
Start (new string [] { "dtest-app.exe" });
}
@@ -167,6 +175,9 @@ public class DebuggerTests
step_req.Disable ();
vm.Resume ();
if (forceExit)
vm.Exit (0);
while (true) {
Event e = GetNextEvent ();
@@ -175,6 +186,7 @@ public class DebuggerTests
vm.Resume ();
}
vm = null;
}
[Test]
@@ -3235,6 +3247,62 @@ public class DebuggerTests
entry_point.DeclaringType.GetMethod ("Main").MakeGenericMethod (new TypeMirror [] { intm });
});
}
[Test]
public void InspectThreadSuspenedOnWaitOne () {
TearDown ();
Start (true, "dtest-app.exe", "wait-one" );
ThreadMirror.NativeTransitions = true;
var evt = run_until ("wait_one");
Assert.IsNotNull (evt, "#1");
var thread = evt.Thread;
Assert.AreEqual (ThreadState.Running, thread.ThreadState, "#1.1");
var frames = thread.GetFrames ();
Assert.IsNotNull (frames, "#2");
Assert.AreEqual (2, frames.Length, "#3");
Assert.AreEqual ("wait_one", frames [0].Method.Name, "#4");
Assert.AreEqual ("Main", frames [1].Method.Name, "#5");
vm.Resume ();
Thread.Sleep (500); //FIXME this is racy, maybe single step? or something?
vm.Suspend ();
Assert.AreEqual (ThreadState.WaitSleepJoin, thread.ThreadState, "#6");
frames = thread.GetFrames ();
Assert.AreEqual (4, frames.Length, "#7");
Assert.AreEqual ("WaitOne_internal", frames [0].Method.Name, "#8");
Assert.AreEqual ("WaitOne", frames [1].Method.Name, "#8.1");
Assert.AreEqual ("wait_one", frames [2].Method.Name, "#9");
Assert.AreEqual ("Main", frames [3].Method.Name, "#10");
var frame = frames [0];
Assert.IsTrue (frame.IsNativeTransition, "#11.1");
try {
frame.GetThis ();
Assert.Fail ("Known limitation - can't get info from m2n frames");
} catch (AbsentInformationException) {}
frame = frames [1];
Assert.IsFalse (frame.IsNativeTransition, "#12.1");
var wait_one_this = frame.GetThis ();
Assert.IsNotNull (wait_one_this, "#12.2");
frame = frames [2];
var locals = frame.GetVisibleVariables ();
Assert.AreEqual (1, locals.Count, "#13.1");
var local_0 = frame.GetValue (locals [0]);
Assert.IsNotNull (local_0, "#13.2");
Assert.AreEqual (wait_one_this, local_0, "#14.2");
}
}
}
@@ -1032,7 +1032,7 @@ namespace MonoTests.System.Net.Sockets {
client.BeginReceive (BRCallback, client);
IPEndPoint ep = new IPEndPoint (Dns.GetHostEntry (string.Empty).AddressList[0], 1237);
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1237);
byte[] send_bytes = new byte[] {10, 11, 12, 13};
client.Send (send_bytes, send_bytes.Length, ep);
@@ -1052,7 +1052,7 @@ namespace MonoTests.System.Net.Sockets {
public void Available ()
{
UdpClient client = new UdpClient (1238);
IPEndPoint ep = new IPEndPoint (Dns.GetHostEntry (string.Empty).AddressList[0], 1238);
IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1238);
byte[] bytes = new byte[] {10, 11, 12, 13};
client.Send (bytes, bytes.Length, ep);
@@ -213,6 +213,9 @@ namespace MonoTests.System.Security.Principal {
}
[Test]
#if __IOS__
[Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=12789")]
#endif
public void SerializeRoundTrip ()
{
WindowsIdentity wi = WindowsIdentity.GetCurrent ();
+4
View File
@@ -305,6 +305,8 @@ rm -rf %buildroot
%_prefix/lib/mono/4.5/System.dll
%_prefix/lib/mono/4.5/cscompmgd.dll
%_prefix/lib/mono/4.5/mscorlib.dll*
%_prefix/lib/mono/4.5/System.Windows.dll
%_prefix/lib/mono/4.5/System.Xml.Serialization.dll
%_prefix/lib/mono/4.5/Facades/*.dll
%_prefix/lib/mono/4.5/Facades/*.dll.mdb
%_prefix/lib/mono/compat-2.0/ICSharpCode.SharpZipLib.dll
@@ -344,6 +346,8 @@ rm -rf %buildroot
%_prefix/lib/mono/gac/System.Xml.Linq
%_prefix/lib/mono/gac/System.Json
%_prefix/lib/mono/gac/System.Json.Microsoft
%_prefix/lib/mono/gac/System.Windows
%_prefix/lib/mono/gac/System.Xml.Serialization
%_prefix/lib/mono/gac/cscompmgd
%_prefix/lib/mono/mono-configuration-crypto
+3
View File
@@ -2297,6 +2297,9 @@ major_scan_card_table (gboolean mod_union, SgenGrayQueue *queue)
*/
if (!card_data)
continue;
#else
g_assert_not_reached ();
card_data = NULL;
#endif
} else {
card_data = card_base = sgen_card_table_get_card_scan_address ((mword)block_start);
+27 -26
View File
@@ -3191,11 +3191,9 @@ add_wrappers (MonoAotCompile *acfg)
}
if (strcmp (acfg->image->assembly->aname.name, "mscorlib") == 0) {
#ifdef MONO_ARCH_HAVE_TLS_GET
MonoMethodDesc *desc;
MonoMethod *orig_method;
int nallocators;
#endif
/* Runtime invoke wrappers */
@@ -3267,34 +3265,34 @@ add_wrappers (MonoAotCompile *acfg)
/* stelemref */
add_method (acfg, mono_marshal_get_stelemref ());
#ifdef MONO_ARCH_HAVE_TLS_GET
/* Managed Allocators */
nallocators = mono_gc_get_managed_allocator_types ();
for (i = 0; i < nallocators; ++i) {
m = mono_gc_get_managed_allocator_by_type (i);
if (m)
add_method (acfg, m);
}
if (MONO_ARCH_HAVE_TLS_GET) {
/* Managed Allocators */
nallocators = mono_gc_get_managed_allocator_types ();
for (i = 0; i < nallocators; ++i) {
m = mono_gc_get_managed_allocator_by_type (i);
if (m)
add_method (acfg, m);
}
/* Monitor Enter/Exit */
desc = mono_method_desc_new ("Monitor:Enter(object,bool&)", FALSE);
orig_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
/* This is a v4 method */
if (orig_method) {
/* Monitor Enter/Exit */
desc = mono_method_desc_new ("Monitor:Enter(object,bool&)", FALSE);
orig_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
/* This is a v4 method */
if (orig_method) {
method = mono_monitor_get_fast_path (orig_method);
if (method)
add_method (acfg, method);
}
mono_method_desc_free (desc);
desc = mono_method_desc_new ("Monitor:Exit(object)", FALSE);
orig_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
g_assert (orig_method);
mono_method_desc_free (desc);
method = mono_monitor_get_fast_path (orig_method);
if (method)
add_method (acfg, method);
add_method (acfg, method);
}
mono_method_desc_free (desc);
desc = mono_method_desc_new ("Monitor:Exit(object)", FALSE);
orig_method = mono_method_desc_search_in_class (desc, mono_defaults.monitor_class);
g_assert (orig_method);
mono_method_desc_free (desc);
method = mono_monitor_get_fast_path (orig_method);
if (method)
add_method (acfg, method);
#endif
/* Stelemref wrappers */
{
@@ -4662,6 +4660,9 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint
case MONO_PATCH_INFO_SIGNATURE:
encode_signature (acfg, (MonoMethodSignature*)patch_info->data.target, p, &p);
break;
case MONO_PATCH_INFO_TLS_OFFSET:
encode_value (GPOINTER_TO_INT (patch_info->data.target), p, &p);
break;
case MONO_PATCH_INFO_GSHAREDVT_CALL:
encode_signature (acfg, (MonoMethodSignature*)patch_info->data.gsharedvt->sig, p, &p);
encode_method_ref (acfg, patch_info->data.gsharedvt->method, p, &p);
+3
View File
@@ -3003,6 +3003,9 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
case MONO_PATCH_INFO_SIGNATURE:
ji->data.target = decode_signature (aot_module, p, &p);
break;
case MONO_PATCH_INFO_TLS_OFFSET:
ji->data.target = GINT_TO_POINTER (decode_value (p, &p));
break;
case MONO_PATCH_INFO_GSHAREDVT_CALL: {
MonoJumpInfoGSharedVtCall *info = g_new0 (MonoJumpInfoGSharedVtCall, 1);
info->sig = decode_signature (aot_module, p, &p);
+1
View File
@@ -300,6 +300,7 @@ bigmul_un: len:2 dest:l src1:a src2:i
sext_i1: dest:i src1:y len:3
sext_i2: dest:i src1:y len:3
tls_get: dest:i len:20
tls_get_reg: dest:i src1:i len:20
atomic_add_i4: src1:b src2:i dest:i len:16
atomic_add_new_i4: src1:b src2:i dest:i len:16
atomic_exchange_i4: src1:b src2:i dest:a len:24
+1 -2
View File
@@ -8365,8 +8365,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
frame = tls->frames [frame_idx];
if (!frame->has_ctx)
// FIXME:
return ERR_INVALID_FRAMEID;
return ERR_ABSENT_INFORMATION;
if (!frame->jit) {
frame->jit = mono_debug_find_method (frame->api_method, frame->domain);
+11
View File
@@ -263,6 +263,15 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
#define NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL)
#define NEW_TLS_OFFSETCONST(cfg,dest,key) do { \
if (cfg->compile_aot) { \
NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_TLS_OFFSET, GINT_TO_POINTER (key)); \
} else { \
int _offset = mini_get_tls_offset ((key)); \
NEW_PCONST ((cfg), (dest), GINT_TO_POINTER (_offset)); \
} \
} while (0)
#define NEW_DECLSECCONST(cfg,dest,image,entry) do { \
if (cfg->compile_aot) { \
NEW_AOTCONST_TOKEN (cfg, dest, MONO_PATCH_INFO_DECLSEC, image, (entry).index, NULL, STACK_OBJ, NULL); \
@@ -443,6 +452,8 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg)
#define EMIT_NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_TLS_OFFSETCONST(cfg,dest,key) do { NEW_TLS_OFFSETCONST ((cfg), (dest), (key)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_DOMAINCONST(cfg,dest) do { NEW_DOMAINCONST ((cfg), (dest)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
#define EMIT_NEW_DECLSECCONST(cfg,dest,image,entry) do { NEW_DECLSECCONST ((cfg), (dest), (image), (entry)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
+77 -59
View File
@@ -2482,7 +2482,7 @@ static MonoInst*
emit_get_rgctx_klass (MonoCompile *cfg, int context_used, MonoClass *klass, MonoRgctxInfoType rgctx_type);
static MonoInst*
mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSignature *sig,
mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSignature *sig, gboolean tail,
MonoInst **args, MonoInst *this, MonoInst *imt_arg, MonoInst *rgctx_arg)
{
#ifndef DISABLE_REMOTING
@@ -2532,7 +2532,7 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
need_unbox_trampoline = method->klass == mono_defaults.object_class || (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE);
call = mono_emit_call_args (cfg, sig, args, FALSE, virtual, FALSE, rgctx_arg ? TRUE : FALSE, need_unbox_trampoline);
call = mono_emit_call_args (cfg, sig, args, FALSE, virtual, tail, rgctx_arg ? TRUE : FALSE, need_unbox_trampoline);
#ifndef DISABLE_REMOTING
if (might_be_remote)
@@ -2542,14 +2542,15 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
call->method = method;
call->inst.flags |= MONO_INST_HAS_METHOD;
call->inst.inst_left = this;
call->tail_call = tail;
if (virtual) {
int vtable_reg, slot_reg, this_reg;
int offset;
this_reg = this->dreg;
#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
if ((method->klass->parent == mono_defaults.multicastdelegate_class) && (!strcmp (method->name, "Invoke"))) {
if (ARCH_HAVE_DELEGATE_TRAMPOLINES && (method->klass->parent == mono_defaults.multicastdelegate_class) && !strcmp (method->name, "Invoke")) {
MonoInst *dummy_use;
MONO_EMIT_NULL_CHECK (cfg, this_reg);
@@ -2576,7 +2577,6 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
return (MonoInst*)call;
}
#endif
if ((!cfg->compile_aot || enable_for_aot) &&
(!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
@@ -2622,17 +2622,17 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
guint32 imt_slot = mono_method_get_imt_slot (method);
emit_imt_argument (cfg, call, call->method, imt_arg);
slot_reg = vtable_reg;
call->inst.inst_offset = ((gint32)imt_slot - MONO_IMT_SIZE) * SIZEOF_VOID_P;
offset = ((gint32)imt_slot - MONO_IMT_SIZE) * SIZEOF_VOID_P;
}
#endif
if (slot_reg == -1) {
slot_reg = alloc_preg (cfg);
mini_emit_load_intf_reg_vtable (cfg, slot_reg, vtable_reg, method->klass);
call->inst.inst_offset = mono_method_get_vtable_index (method) * SIZEOF_VOID_P;
offset = mono_method_get_vtable_index (method) * SIZEOF_VOID_P;
}
} else {
slot_reg = vtable_reg;
call->inst.inst_offset = G_STRUCT_OFFSET (MonoVTable, vtable) +
offset = G_STRUCT_OFFSET (MonoVTable, vtable) +
((mono_method_get_vtable_index (method)) * (SIZEOF_VOID_P));
#ifdef MONO_ARCH_HAVE_IMT
if (imt_arg) {
@@ -2643,6 +2643,7 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
}
call->inst.sreg1 = slot_reg;
call->inst.inst_offset = offset;
call->virtual = TRUE;
}
}
@@ -2658,7 +2659,7 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
MonoInst*
mono_emit_method_call (MonoCompile *cfg, MonoMethod *method, MonoInst **args, MonoInst *this)
{
return mono_emit_method_call_full (cfg, method, mono_method_signature (method), args, this, NULL, NULL);
return mono_emit_method_call_full (cfg, method, mono_method_signature (method), FALSE, args, this, NULL, NULL);
}
MonoInst*
@@ -3465,7 +3466,7 @@ handle_unbox_nullable (MonoCompile* cfg, MonoInst* val, MonoClass* klass, int co
EMIT_NEW_VTABLECONST (cfg, rgctx_arg, vtable);
}
return mono_emit_method_call_full (cfg, method, NULL, &val, NULL, NULL, rgctx_arg);
return mono_emit_method_call_full (cfg, method, NULL, FALSE, &val, NULL, NULL, rgctx_arg);
}
}
@@ -3720,7 +3721,7 @@ handle_box (MonoCompile *cfg, MonoInst *val, MonoClass *klass, int context_used,
EMIT_NEW_VTABLECONST (cfg, rgctx_arg, vtable);
}
return mono_emit_method_call_full (cfg, method, NULL, &val, NULL, NULL, rgctx_arg);
return mono_emit_method_call_full (cfg, method, NULL, FALSE, &val, NULL, NULL, rgctx_arg);
}
}
@@ -7448,6 +7449,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
MonoInst *vtable_arg = NULL;
gboolean check_this = FALSE;
gboolean supported_tail_call = FALSE;
gboolean tail_call = FALSE;
gboolean need_seq_point = FALSE;
guint32 call_opcode = *ip;
gboolean emit_widen = TRUE;
@@ -7843,7 +7845,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
g_assert (cmethod->is_inflated);
imt_arg = emit_get_rgctx_method (cfg, context_used,
cmethod, MONO_RGCTX_INFO_METHOD);
ins = mono_emit_method_call_full (cfg, cmethod, fsig, sp, sp [0], imt_arg, NULL);
ins = mono_emit_method_call_full (cfg, cmethod, fsig, FALSE, sp, sp [0], imt_arg, NULL);
} else {
this_temp = mono_compile_create_var (cfg, type_from_stack_type (sp [0]), OP_LOCAL);
NEW_TEMPSTORE (cfg, store, this_temp->inst_c0, sp [0]);
@@ -8143,11 +8145,14 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* FIXME: Enabling TAILC breaks some inlining/stack trace/etc tests */
/* FIXME: runtime generic context pointer for jumps? */
/* FIXME: handle this for generic sharing eventually */
if (cmethod &&
((((ins_flag & MONO_INST_TAILCALL) && (call_opcode == CEE_CALL))
))//|| ((cfg->opt & MONO_OPT_TAILC) && *ip == CEE_CALL && ip [5] == CEE_RET))
&& !vtable_arg && !cfg->generic_sharing_context && is_supported_tail_call (cfg, method, cmethod, fsig))
if (cmethod && (ins_flag & MONO_INST_TAILCALL) &&
!vtable_arg && !cfg->generic_sharing_context && is_supported_tail_call (cfg, method, cmethod, fsig))
supported_tail_call = TRUE;
if (supported_tail_call) {
if (call_opcode != CEE_CALL)
supported_tail_call = FALSE;
}
if (supported_tail_call) {
MonoCallInst *call;
@@ -8156,45 +8161,44 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
//printf ("HIT: %s -> %s\n", mono_method_full_name (cfg->method, TRUE), mono_method_full_name (cmethod, TRUE));
#ifdef MONO_ARCH_USE_OP_TAIL_CALL
/* Handle tail calls similarly to calls */
call = mono_emit_call_args (cfg, mono_method_signature (cmethod), sp, FALSE, FALSE, TRUE, FALSE, FALSE);
#else
MONO_INST_NEW_CALL (cfg, call, OP_JMP);
call->tail_call = TRUE;
call->method = cmethod;
call->signature = mono_method_signature (cmethod);
if (ARCH_USE_OP_TAIL_CALL) {
/* Handle tail calls similarly to normal calls */
tail_call = TRUE;
} else {
MONO_INST_NEW_CALL (cfg, call, OP_JMP);
call->tail_call = TRUE;
call->method = cmethod;
call->signature = mono_method_signature (cmethod);
/*
* We implement tail calls by storing the actual arguments into the
* argument variables, then emitting a CEE_JMP.
*/
for (i = 0; i < n; ++i) {
/* Prevent argument from being register allocated */
arg_array [i]->flags |= MONO_INST_VOLATILE;
EMIT_NEW_ARGSTORE (cfg, ins, i, sp [i]);
/*
* We implement tail calls by storing the actual arguments into the
* argument variables, then emitting a CEE_JMP.
*/
for (i = 0; i < n; ++i) {
/* Prevent argument from being register allocated */
arg_array [i]->flags |= MONO_INST_VOLATILE;
EMIT_NEW_ARGSTORE (cfg, ins, i, sp [i]);
}
ins = (MonoInst*)call;
ins->inst_p0 = cmethod;
ins->inst_p1 = arg_array [0];
MONO_ADD_INS (bblock, ins);
link_bblock (cfg, bblock, end_bblock);
start_new_bblock = 1;
// FIXME: Eliminate unreachable epilogs
/*
* OP_TAILCALL has no return value, so skip the CEE_RET if it is
* only reachable from this call.
*/
GET_BBLOCK (cfg, tblock, ip + 5);
if (tblock == bblock || tblock->in_count == 0)
skip_ret = TRUE;
push_res = FALSE;
goto call_end;
}
#endif
ins = (MonoInst*)call;
ins->inst_p0 = cmethod;
ins->inst_p1 = arg_array [0];
MONO_ADD_INS (bblock, ins);
link_bblock (cfg, bblock, end_bblock);
start_new_bblock = 1;
// FIXME: Eliminate unreachable epilogs
/*
* OP_TAILCALL has no return value, so skip the CEE_RET if it is
* only reachable from this call.
*/
GET_BBLOCK (cfg, tblock, ip + 5);
if (tblock == bblock || tblock->in_count == 0)
skip_ret = TRUE;
push_res = FALSE;
goto call_end;
}
/*
@@ -8210,9 +8214,25 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* Common call */
INLINE_FAILURE ("call");
ins = mono_emit_method_call_full (cfg, cmethod, fsig, sp, virtual ? sp [0] : NULL,
ins = mono_emit_method_call_full (cfg, cmethod, fsig, tail_call, sp, virtual ? sp [0] : NULL,
imt_arg, vtable_arg);
if (tail_call) {
link_bblock (cfg, bblock, end_bblock);
start_new_bblock = 1;
// FIXME: Eliminate unreachable epilogs
/*
* OP_TAILCALL has no return value, so skip the CEE_RET if it is
* only reachable from this call.
*/
GET_BBLOCK (cfg, tblock, ip + 5);
if (tblock == bblock || tblock->in_count == 0)
skip_ret = TRUE;
push_res = FALSE;
}
call_end:
/* End of call, INS should contain the result of the call, if any */
@@ -9137,7 +9157,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* we simply pass a null pointer */
EMIT_NEW_PCONST (cfg, *sp, NULL);
/* now call the string ctor */
alloc = mono_emit_method_call_full (cfg, cmethod, fsig, sp, NULL, NULL, NULL);
alloc = mono_emit_method_call_full (cfg, cmethod, fsig, FALSE, sp, NULL, NULL, NULL);
} else {
MonoInst* callvirt_this_arg = NULL;
@@ -9211,7 +9231,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
// FIXME-VT: Clean this up
if (cfg->gsharedvt && mini_is_gsharedvt_signature (cfg, fsig))
GSHAREDVT_FAILURE(*ip);
mono_emit_method_call_full (cfg, cmethod, fsig, sp, callvirt_this_arg, NULL, NULL);
mono_emit_method_call_full (cfg, cmethod, fsig, FALSE, sp, callvirt_this_arg, NULL, NULL);
}
} else if (cfg->gsharedvt && mini_is_gsharedvt_signature (cfg, fsig)) {
MonoInst *addr;
@@ -9229,7 +9249,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
mono_emit_calli (cfg, fsig, sp, cmethod_addr, NULL, vtable_arg);
} else {
INLINE_FAILURE ("ctor call");
ins = mono_emit_method_call_full (cfg, cmethod, fsig, sp,
ins = mono_emit_method_call_full (cfg, cmethod, fsig, FALSE, sp,
callvirt_this_arg, NULL, vtable_arg);
}
}
@@ -11085,7 +11105,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
lmf_ins = mono_get_lmf_intrinsic (cfg);
#endif
#ifdef MONO_ARCH_HAVE_TLS_GET
if (MONO_ARCH_HAVE_TLS_GET && ad_ins && lmf_ins) {
NEW_BBLOCK (cfg, next_bb);
@@ -11097,7 +11116,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, lmf_ins->dreg, 0);
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, next_bb);
}
#endif
if (cfg->compile_aot) {
/* AOT code is only used in the root domain */
+1 -1
View File
@@ -4818,7 +4818,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
}
offset = code - cfg->native_code;
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, ins->inst_p0);
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call->method);
if (cfg->compile_aot)
amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, 8);
else
+1 -1
View File
@@ -706,7 +706,7 @@ mono_arch_cpu_init (void)
#if defined(__ARM_EABI__)
eabi_supported = TRUE;
#endif
#if defined(__APPLE__) && defined(MONO_CROSS_COMPILE)
#if defined(__APPLE__)
i8_align = 4;
#else
i8_align = __alignof__ (gint64);
+1
View File
@@ -608,6 +608,7 @@ MINI_OP(OP_CARD_TABLE_WBARRIER, "card_table_wbarrier", NONE, IREG, IREG)
/* arch-dep tls access */
MINI_OP(OP_TLS_GET, "tls_get", IREG, NONE, NONE)
MINI_OP(OP_TLS_GET_REG, "tls_get_reg", IREG, IREG, NONE)
MINI_OP(OP_LOAD_GOTADDR, "load_gotaddr", IREG, NONE, NONE)
MINI_OP(OP_DUMMY_USE, "dummy_use", NONE, IREG, NONE)
+1 -1
View File
@@ -3788,7 +3788,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
}
ppc_mr (code, ppc_sp, ppc_r11);
mono_add_patch_info (cfg, (guint8*) code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, ins->inst_p0);
mono_add_patch_info (cfg, (guint8*) code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call->method);
if (cfg->compile_aot) {
/* arch_emit_got_access () patches this */
ppc_load32 (code, ppc_r0, 0);
+16 -1
View File
@@ -3278,7 +3278,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
/* restore ESP/EBP */
x86_leave (code);
offset = code - cfg->native_code;
mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_METHOD_JUMP, ins->inst_p0);
mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_METHOD_JUMP, call->method);
x86_jump32 (code, 0);
ins->flags |= MONO_INST_GC_CALLSITE;
@@ -4201,6 +4201,21 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
code = mono_x86_emit_tls_get (code, ins->dreg, ins->inst_offset);
break;
}
case OP_TLS_GET_REG: {
#ifdef __APPLE__
// FIXME: tls_gs_offset can change too, do these when calculating the tls offset
if (ins->dreg != ins->sreg1)
x86_mov_reg_reg (code, ins->dreg, ins->sreg1, sizeof (gpointer));
x86_shift_reg_imm (code, X86_SHL, ins->dreg, 2);
if (tls_gs_offset)
x86_alu_reg_imm (code, X86_ADD, ins->dreg, tls_gs_offset);
x86_prefix (code, X86_GS_PREFIX);
x86_mov_reg_membase (code, ins->dreg, ins->dreg, 0, sizeof (gpointer));
#else
g_assert_not_reached ();
#endif
break;
}
case OP_MEMORY_BARRIER: {
/* x86 only needs barrier for StoreLoad and FullBarrier */
switch (ins->backend.memory_barrier_kind) {
+4
View File
@@ -263,6 +263,10 @@ typedef struct {
#define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
#define MONO_ARCH_GSHAREDVT_SUPPORTED 1
#ifdef TARGET_OSX
#define MONO_ARCH_HAVE_TLS_GET_REG 1
#endif
gboolean
mono_x86_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL;
+64 -19
View File
@@ -65,6 +65,7 @@
#include <ctype.h>
#include "trace.h"
#include "version.h"
#include "ir-emit.h"
#include "jit-icalls.h"
@@ -2847,47 +2848,91 @@ mini_thread_cleanup (MonoInternalThread *thread)
}
}
static MonoInst*
mono_create_tls_get (MonoCompile *cfg, int offset)
int
mini_get_tls_offset (MonoJitTlsKey key)
{
#ifdef MONO_ARCH_HAVE_TLS_GET
if (MONO_ARCH_HAVE_TLS_GET) {
MonoInst* ins;
int offset;
if (offset == -1)
return NULL;
switch (key) {
case TLS_KEY_THREAD:
offset = mono_thread_get_tls_offset ();
break;
case TLS_KEY_JIT_TLS:
offset = mono_get_jit_tls_offset ();
break;
case TLS_KEY_DOMAIN:
offset = mono_domain_get_tls_offset ();
break;
case TLS_KEY_LMF:
offset = mono_get_lmf_tls_offset ();
break;
default:
g_assert_not_reached ();
offset = -1;
break;
}
return offset;
}
MONO_INST_NEW (cfg, ins, OP_TLS_GET);
static MonoInst*
mono_create_tls_get_offset (MonoCompile *cfg, int offset)
{
MonoInst* ins;
if (!MONO_ARCH_HAVE_TLS_GET)
return NULL;
if (offset == -1)
return NULL;
MONO_INST_NEW (cfg, ins, OP_TLS_GET);
ins->dreg = mono_alloc_preg (cfg);
ins->inst_offset = offset;
return ins;
}
static MonoInst*
mono_create_tls_get (MonoCompile *cfg, MonoJitTlsKey key)
{
/*
* TLS offsets might be different at AOT time, so load them from a GOT slot and
* use a different opcode.
*/
if (cfg->compile_aot && MONO_ARCH_HAVE_TLS_GET && ARCH_HAVE_TLS_GET_REG) {
MonoInst *ins, *c;
EMIT_NEW_TLS_OFFSETCONST (cfg, c, key);
MONO_INST_NEW (cfg, ins, OP_TLS_GET_REG);
ins->dreg = mono_alloc_preg (cfg);
ins->inst_offset = offset;
ins->sreg1 = c->dreg;
return ins;
}
#endif
return NULL;
return mono_create_tls_get_offset (cfg, mini_get_tls_offset (key));
}
MonoInst*
mono_get_jit_tls_intrinsic (MonoCompile *cfg)
{
return mono_create_tls_get (cfg, mono_get_jit_tls_offset ());
return mono_create_tls_get (cfg, TLS_KEY_JIT_TLS);
}
MonoInst*
mono_get_domain_intrinsic (MonoCompile* cfg)
{
return mono_create_tls_get (cfg, mono_domain_get_tls_offset ());
return mono_create_tls_get (cfg, TLS_KEY_DOMAIN);
}
MonoInst*
mono_get_thread_intrinsic (MonoCompile* cfg)
{
return mono_create_tls_get (cfg, mono_thread_get_tls_offset ());
return mono_create_tls_get (cfg, TLS_KEY_THREAD);
}
MonoInst*
mono_get_lmf_intrinsic (MonoCompile* cfg)
{
return mono_create_tls_get (cfg, mono_get_lmf_tls_offset ());
return mono_create_tls_get (cfg, TLS_KEY_LMF);
}
void
@@ -3027,6 +3072,7 @@ mono_patch_info_hash (gconstpointer data)
case MONO_PATCH_INFO_METHOD_RGCTX:
case MONO_PATCH_INFO_DELEGATE_TRAMPOLINE:
case MONO_PATCH_INFO_SIGNATURE:
case MONO_PATCH_INFO_TLS_OFFSET:
return (ji->type << 8) | (gssize)ji->data.target;
case MONO_PATCH_INFO_GSHAREDVT_CALL:
return (ji->type << 8) | (gssize)ji->data.gsharedvt->method;
@@ -3459,6 +3505,9 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
target = (gpointer) (size_t) mono_jit_tls_id;
break;
}
case MONO_PATCH_INFO_TLS_OFFSET:
target = GINT_TO_POINTER (mini_get_tls_offset (GPOINTER_TO_INT (patch_info->data.target)));
break;
default:
g_assert_not_reached ();
}
@@ -6849,11 +6898,7 @@ mini_init (const char *filename, const char *runtime_version)
#endif
#endif
#ifdef MONO_ARCH_HAVE_TLS_GET
mono_runtime_set_has_tls_get (MONO_ARCH_HAVE_TLS_GET);
#else
mono_runtime_set_has_tls_get (FALSE);
#endif
if (!global_codeman)
global_codeman = mono_code_manager_new ();
+33
View File
@@ -1046,6 +1046,16 @@ typedef struct {
gboolean orig_ex_ctx_set;
} MonoJitTlsData;
/* TLS entries used by JITted code */
typedef enum {
/* mono_thread_internal_current () */
TLS_KEY_THREAD = 0,
TLS_KEY_JIT_TLS = 1,
/* mono_domain_get () */
TLS_KEY_DOMAIN = 2,
TLS_KEY_LMF = 3
} MonoJitTlsKey;
/*
* This structure is an extension of MonoLMF and contains extra information.
*/
@@ -1955,6 +1965,7 @@ MonoNativeTlsKey mono_get_jit_tls_key (void) MONO_INTERNAL;
gint32 mono_get_jit_tls_offset (void) MONO_INTERNAL;
gint32 mono_get_lmf_tls_offset (void) MONO_INTERNAL;
gint32 mono_get_lmf_addr_tls_offset (void) MONO_INTERNAL;
int mini_get_tls_offset (MonoJitTlsKey key) MONO_INTERNAL;
MonoInst* mono_get_jit_tls_intrinsic (MonoCompile *cfg) MONO_INTERNAL;
MonoInst* mono_get_domain_intrinsic (MonoCompile* cfg) MONO_INTERNAL;
MonoInst* mono_get_thread_intrinsic (MonoCompile* cfg) MONO_INTERNAL;
@@ -2722,4 +2733,26 @@ void SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler) MONO_INTERNAL;
void SIG_HANDLER_SIGNATURE (mono_sigint_signal_handler) MONO_INTERNAL;
gboolean SIG_HANDLER_SIGNATURE (mono_chain_signal) MONO_INTERNAL;
#ifdef MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
#define ARCH_HAVE_DELEGATE_TRAMPOLINES 1
#else
#define ARCH_HAVE_DELEGATE_TRAMPOLINES 0
#endif
#ifdef MONO_ARCH_USE_OP_TAIL_CALL
#define ARCH_USE_OP_TAIL_CALL 1
#else
#define ARCH_USE_OP_TAIL_CALL 0
#endif
#ifndef MONO_ARCH_HAVE_TLS_GET
#define MONO_ARCH_HAVE_TLS_GET 0
#endif
#ifdef MONO_ARCH_HAVE_TLS_GET_REG
#define ARCH_HAVE_TLS_GET_REG 1
#else
#define ARCH_HAVE_TLS_GET_REG 0
#endif
#endif /* __MONO_MINI_H__ */
+3
View File
@@ -48,5 +48,8 @@ PATCH_INFO(SIGNATURE, "signature")
PATCH_INFO(GSHAREDVT_CALL, "gsharedvt_call")
PATCH_INFO(GSHAREDVT_METHOD, "gsharedvt_method")
PATCH_INFO(JIT_TLS_ID, "jit_tls_id")
PATCH_INFO(TLS_OFFSET, "tls_offset")
PATCH_INFO(NONE, "none")