cairo: Introduce 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. This is a merge from changes in Mono.Cairo in mono 3.2.
This commit is contained in:
parent
5a78a5d177
commit
38d1a3f13e
24 changed files with 773 additions and 828 deletions
275
cairo/Context.cs
275
cairo/Context.cs
|
@ -190,7 +190,7 @@ namespace Cairo {
|
|||
|
||||
public class Context : IDisposable
|
||||
{
|
||||
internal IntPtr state = IntPtr.Zero;
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
|
||||
static int native_glyph_size, c_compiler_long_size;
|
||||
|
||||
|
@ -222,16 +222,22 @@ namespace Cairo {
|
|||
}
|
||||
}
|
||||
|
||||
public Context (Surface surface)
|
||||
public Context (Surface surface) : this (NativeMethods.cairo_create (surface.Handle), true)
|
||||
{
|
||||
state = NativeMethods.cairo_create (surface.Handle);
|
||||
}
|
||||
|
||||
public Context (IntPtr state) : this (state, true) {}
|
||||
|
||||
public Context (IntPtr state, bool owned)
|
||||
public Context (IntPtr handle, bool owner)
|
||||
{
|
||||
this.handle = handle;
|
||||
if (!owner)
|
||||
NativeMethods.cairo_reference (handle);
|
||||
if (CairoDebug.Enabled)
|
||||
CairoDebug.OnAllocated (handle);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public Context (IntPtr state) : this (state, true)
|
||||
{
|
||||
this.state = owned ? state : NativeMethods.cairo_reference (state);
|
||||
}
|
||||
|
||||
~Context ()
|
||||
|
@ -239,7 +245,7 @@ namespace Cairo {
|
|||
Dispose (false);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose ()
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
|
@ -248,61 +254,60 @@ namespace Cairo {
|
|||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposing || CairoDebug.Enabled)
|
||||
CairoDebug.OnDisposed<Context> (state, disposing);
|
||||
CairoDebug.OnDisposed<Context> (handle, disposing);
|
||||
|
||||
if (!disposing|| state == IntPtr.Zero)
|
||||
if (!disposing || handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
//Console.WriteLine ("Destroying");
|
||||
NativeMethods.cairo_destroy (state);
|
||||
state = IntPtr.Zero;
|
||||
NativeMethods.cairo_destroy (handle);
|
||||
handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
public void Save ()
|
||||
{
|
||||
NativeMethods.cairo_save (state);
|
||||
NativeMethods.cairo_save (handle);
|
||||
}
|
||||
|
||||
public void Restore ()
|
||||
{
|
||||
NativeMethods.cairo_restore (state);
|
||||
NativeMethods.cairo_restore (handle);
|
||||
}
|
||||
|
||||
public Antialias Antialias {
|
||||
get { return NativeMethods.cairo_get_antialias (state); }
|
||||
set { NativeMethods.cairo_set_antialias (state, value); }
|
||||
get { return NativeMethods.cairo_get_antialias (handle); }
|
||||
set { NativeMethods.cairo_set_antialias (handle, value); }
|
||||
}
|
||||
|
||||
public Cairo.Status Status {
|
||||
get {
|
||||
return NativeMethods.cairo_status (state);
|
||||
return NativeMethods.cairo_status (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public IntPtr Handle {
|
||||
get {
|
||||
return state;
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
public Cairo.Operator Operator {
|
||||
public Operator Operator {
|
||||
set {
|
||||
NativeMethods.cairo_set_operator (state, value);
|
||||
NativeMethods.cairo_set_operator (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
return NativeMethods.cairo_get_operator (state);
|
||||
return NativeMethods.cairo_get_operator (handle);
|
||||
}
|
||||
}
|
||||
|
||||
//FIXME: obsolete this property
|
||||
public Cairo.Color Color {
|
||||
[Obsolete ("Use SetSourceRGBA method")]
|
||||
public Color Color {
|
||||
set {
|
||||
NativeMethods.cairo_set_source_rgba (state, value.R, value.G, value.B, value.A);
|
||||
NativeMethods.cairo_set_source_rgba (handle, value.R, value.G, value.B, value.A);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete ("Use Color property")]
|
||||
[Obsolete ("Use SetSourceRGBA method")]
|
||||
public Cairo.Color ColorRgb {
|
||||
set {
|
||||
Color = new Color (value.R, value.G, value.B);
|
||||
|
@ -311,165 +316,166 @@ namespace Cairo {
|
|||
|
||||
public double Tolerance {
|
||||
get {
|
||||
return NativeMethods.cairo_get_tolerance (state);
|
||||
return NativeMethods.cairo_get_tolerance (handle);
|
||||
}
|
||||
|
||||
set {
|
||||
NativeMethods.cairo_set_tolerance (state, value);
|
||||
NativeMethods.cairo_set_tolerance (handle, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Cairo.FillRule FillRule {
|
||||
set {
|
||||
NativeMethods.cairo_set_fill_rule (state, value);
|
||||
NativeMethods.cairo_set_fill_rule (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
return NativeMethods.cairo_get_fill_rule (state);
|
||||
return NativeMethods.cairo_get_fill_rule (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public double LineWidth {
|
||||
set {
|
||||
NativeMethods.cairo_set_line_width (state, value);
|
||||
NativeMethods.cairo_set_line_width (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
return NativeMethods.cairo_get_line_width (state);
|
||||
return NativeMethods.cairo_get_line_width (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public Cairo.LineCap LineCap {
|
||||
set {
|
||||
NativeMethods.cairo_set_line_cap (state, value);
|
||||
NativeMethods.cairo_set_line_cap (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
return NativeMethods.cairo_get_line_cap (state);
|
||||
return NativeMethods.cairo_get_line_cap (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public Cairo.LineJoin LineJoin {
|
||||
set {
|
||||
NativeMethods.cairo_set_line_join (state, value);
|
||||
NativeMethods.cairo_set_line_join (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
return NativeMethods.cairo_get_line_join (state);
|
||||
return NativeMethods.cairo_get_line_join (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDash (double [] dashes, double offset)
|
||||
{
|
||||
NativeMethods.cairo_set_dash (state, dashes, dashes.Length, offset);
|
||||
NativeMethods.cairo_set_dash (handle, dashes, dashes.Length, offset);
|
||||
}
|
||||
|
||||
[Obsolete("Use Source")]
|
||||
public Pattern Pattern {
|
||||
set {
|
||||
NativeMethods.cairo_set_source (state, value.Handle);
|
||||
Source = value;
|
||||
}
|
||||
|
||||
get {
|
||||
return new Pattern (NativeMethods.cairo_get_source (state));
|
||||
return Source;
|
||||
}
|
||||
}
|
||||
|
||||
public Pattern Source {
|
||||
set {
|
||||
NativeMethods.cairo_set_source (state, value.Handle);
|
||||
NativeMethods.cairo_set_source (handle, value.Handle);
|
||||
}
|
||||
|
||||
get {
|
||||
return Pattern.Lookup (NativeMethods.cairo_get_source (state));
|
||||
var ptr = NativeMethods.cairo_get_source (handle);
|
||||
return Cairo.Pattern.Lookup (ptr, false);
|
||||
}
|
||||
}
|
||||
|
||||
public double MiterLimit {
|
||||
set {
|
||||
NativeMethods.cairo_set_miter_limit (state, value);
|
||||
NativeMethods.cairo_set_miter_limit (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
return NativeMethods.cairo_get_miter_limit (state);
|
||||
return NativeMethods.cairo_get_miter_limit (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public PointD CurrentPoint {
|
||||
get {
|
||||
double x, y;
|
||||
NativeMethods.cairo_get_current_point (state, out x, out y);
|
||||
NativeMethods.cairo_get_current_point (handle, out x, out y);
|
||||
return new PointD (x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCurrentPoint {
|
||||
get { return NativeMethods.cairo_has_current_point (state); }
|
||||
get { return NativeMethods.cairo_has_current_point (handle); }
|
||||
}
|
||||
|
||||
public Cairo.Surface Target {
|
||||
set {
|
||||
if (state != IntPtr.Zero)
|
||||
NativeMethods.cairo_destroy (state);
|
||||
if (handle != IntPtr.Zero)
|
||||
NativeMethods.cairo_destroy (handle);
|
||||
|
||||
state = NativeMethods.cairo_create (value.Handle);
|
||||
handle = NativeMethods.cairo_create (value.Handle);
|
||||
}
|
||||
|
||||
get {
|
||||
return Cairo.Surface.LookupExternalSurface (
|
||||
NativeMethods.cairo_get_target (state));
|
||||
return Surface.Lookup (NativeMethods.cairo_get_target (handle), false);
|
||||
}
|
||||
}
|
||||
|
||||
public Cairo.ScaledFont ScaledFont {
|
||||
set {
|
||||
NativeMethods.cairo_set_scaled_font (state, value.Handle);
|
||||
NativeMethods.cairo_set_scaled_font (handle, value.Handle);
|
||||
}
|
||||
|
||||
get {
|
||||
return new ScaledFont (NativeMethods.cairo_get_scaled_font (state));
|
||||
return new ScaledFont (NativeMethods.cairo_get_scaled_font (handle), false);
|
||||
}
|
||||
}
|
||||
|
||||
public uint ReferenceCount {
|
||||
get { return NativeMethods.cairo_get_reference_count (state); }
|
||||
get { return NativeMethods.cairo_get_reference_count (handle); }
|
||||
}
|
||||
|
||||
public void SetSourceRGB (double r, double g, double b)
|
||||
{
|
||||
NativeMethods.cairo_set_source_rgb (state, r, g, b);
|
||||
NativeMethods.cairo_set_source_rgb (handle, r, g, b);
|
||||
}
|
||||
|
||||
public void SetSourceRGBA (double r, double g, double b, double a)
|
||||
{
|
||||
NativeMethods.cairo_set_source_rgba (state, r, g, b, a);
|
||||
NativeMethods.cairo_set_source_rgba (handle, r, g, b, a);
|
||||
}
|
||||
|
||||
//[Obsolete ("Use SetSource method (with double parameters)")]
|
||||
public void SetSourceSurface (Surface source, int x, int y)
|
||||
{
|
||||
NativeMethods.cairo_set_source_surface (state, source.Handle, x, y);
|
||||
NativeMethods.cairo_set_source_surface (handle, source.Handle, x, y);
|
||||
}
|
||||
|
||||
public void SetSource (Surface source, double x, double y)
|
||||
{
|
||||
NativeMethods.cairo_set_source_surface (state, source.Handle, x, y);
|
||||
NativeMethods.cairo_set_source_surface (handle, source.Handle, x, y);
|
||||
}
|
||||
|
||||
public void SetSource (Surface source)
|
||||
{
|
||||
NativeMethods.cairo_set_source_surface (state, source.Handle, 0, 0);
|
||||
NativeMethods.cairo_set_source_surface (handle, source.Handle, 0, 0);
|
||||
}
|
||||
|
||||
#region Path methods
|
||||
|
||||
public void NewPath ()
|
||||
{
|
||||
NativeMethods.cairo_new_path (state);
|
||||
NativeMethods.cairo_new_path (handle);
|
||||
}
|
||||
|
||||
public void NewSubPath ()
|
||||
{
|
||||
NativeMethods.cairo_new_sub_path (state);
|
||||
NativeMethods.cairo_new_sub_path (handle);
|
||||
}
|
||||
|
||||
public void MoveTo (PointD p)
|
||||
|
@ -479,7 +485,7 @@ namespace Cairo {
|
|||
|
||||
public void MoveTo (double x, double y)
|
||||
{
|
||||
NativeMethods.cairo_move_to (state, x, y);
|
||||
NativeMethods.cairo_move_to (handle, x, y);
|
||||
}
|
||||
|
||||
public void LineTo (PointD p)
|
||||
|
@ -489,7 +495,7 @@ namespace Cairo {
|
|||
|
||||
public void LineTo (double x, double y)
|
||||
{
|
||||
NativeMethods.cairo_line_to (state, x, y);
|
||||
NativeMethods.cairo_line_to (handle, x, y);
|
||||
}
|
||||
|
||||
public void CurveTo (PointD p1, PointD p2, PointD p3)
|
||||
|
@ -499,7 +505,7 @@ namespace Cairo {
|
|||
|
||||
public void CurveTo (double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
NativeMethods.cairo_curve_to (state, x1, y1, x2, y2, x3, y3);
|
||||
NativeMethods.cairo_curve_to (handle, x1, y1, x2, y2, x3, y3);
|
||||
}
|
||||
|
||||
public void RelMoveTo (Distance d)
|
||||
|
@ -509,7 +515,7 @@ namespace Cairo {
|
|||
|
||||
public void RelMoveTo (double dx, double dy)
|
||||
{
|
||||
NativeMethods.cairo_rel_move_to (state, dx, dy);
|
||||
NativeMethods.cairo_rel_move_to (handle, dx, dy);
|
||||
}
|
||||
|
||||
public void RelLineTo (Distance d)
|
||||
|
@ -519,7 +525,7 @@ namespace Cairo {
|
|||
|
||||
public void RelLineTo (double dx, double dy)
|
||||
{
|
||||
NativeMethods.cairo_rel_line_to (state, dx, dy);
|
||||
NativeMethods.cairo_rel_line_to (handle, dx, dy);
|
||||
}
|
||||
|
||||
public void RelCurveTo (Distance d1, Distance d2, Distance d3)
|
||||
|
@ -529,17 +535,17 @@ namespace Cairo {
|
|||
|
||||
public void RelCurveTo (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
|
||||
{
|
||||
NativeMethods.cairo_rel_curve_to (state, dx1, dy1, dx2, dy2, dx3, dy3);
|
||||
NativeMethods.cairo_rel_curve_to (handle, dx1, dy1, dx2, dy2, dx3, dy3);
|
||||
}
|
||||
|
||||
public void Arc (double xc, double yc, double radius, double angle1, double angle2)
|
||||
{
|
||||
NativeMethods.cairo_arc (state, xc, yc, radius, angle1, angle2);
|
||||
NativeMethods.cairo_arc (handle, xc, yc, radius, angle1, angle2);
|
||||
}
|
||||
|
||||
public void ArcNegative (double xc, double yc, double radius, double angle1, double angle2)
|
||||
{
|
||||
NativeMethods.cairo_arc_negative (state, xc, yc, radius, angle1, angle2);
|
||||
NativeMethods.cairo_arc_negative (handle, xc, yc, radius, angle1, angle2);
|
||||
}
|
||||
|
||||
public void Rectangle (Rectangle rectangle)
|
||||
|
@ -554,32 +560,32 @@ namespace Cairo {
|
|||
|
||||
public void Rectangle (double x, double y, double width, double height)
|
||||
{
|
||||
NativeMethods.cairo_rectangle (state, x, y, width, height);
|
||||
NativeMethods.cairo_rectangle (handle, x, y, width, height);
|
||||
}
|
||||
|
||||
public void ClosePath ()
|
||||
{
|
||||
NativeMethods.cairo_close_path (state);
|
||||
NativeMethods.cairo_close_path (handle);
|
||||
}
|
||||
|
||||
public Path CopyPath ()
|
||||
{
|
||||
return new Path (NativeMethods.cairo_copy_path (state));
|
||||
return new Path (NativeMethods.cairo_copy_path (handle));
|
||||
}
|
||||
|
||||
public Path CopyPathFlat ()
|
||||
{
|
||||
return new Path (NativeMethods.cairo_copy_path_flat (state));
|
||||
return new Path (NativeMethods.cairo_copy_path_flat (handle));
|
||||
}
|
||||
|
||||
public void AppendPath (Path path)
|
||||
{
|
||||
NativeMethods.cairo_append_path (state, path.handle);
|
||||
NativeMethods.cairo_append_path (handle, path.Handle);
|
||||
}
|
||||
|
||||
public void PathExtents (out double x1, out double y1, out double x2, out double y2)
|
||||
{
|
||||
NativeMethods.cairo_path_extents (state, out x1, out y1, out x2, out y2);
|
||||
NativeMethods.cairo_path_extents (handle, out x1, out y1, out x2, out y2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -587,204 +593,201 @@ namespace Cairo {
|
|||
#region Painting Methods
|
||||
public void Paint ()
|
||||
{
|
||||
NativeMethods.cairo_paint (state);
|
||||
NativeMethods.cairo_paint (handle);
|
||||
}
|
||||
|
||||
public void PaintWithAlpha (double alpha)
|
||||
{
|
||||
NativeMethods.cairo_paint_with_alpha (state, alpha);
|
||||
NativeMethods.cairo_paint_with_alpha (handle, alpha);
|
||||
}
|
||||
|
||||
public void Mask (Pattern pattern)
|
||||
{
|
||||
NativeMethods.cairo_mask (state, pattern.Handle);
|
||||
NativeMethods.cairo_mask (handle, pattern.Handle);
|
||||
}
|
||||
|
||||
public void MaskSurface (Surface surface, double surface_x, double surface_y)
|
||||
{
|
||||
NativeMethods.cairo_mask_surface (state, surface.Handle, surface_x, surface_y);
|
||||
NativeMethods.cairo_mask_surface (handle, surface.Handle, surface_x, surface_y);
|
||||
}
|
||||
|
||||
public void Stroke ()
|
||||
{
|
||||
NativeMethods.cairo_stroke (state);
|
||||
NativeMethods.cairo_stroke (handle);
|
||||
}
|
||||
|
||||
public void StrokePreserve ()
|
||||
{
|
||||
NativeMethods.cairo_stroke_preserve (state);
|
||||
NativeMethods.cairo_stroke_preserve (handle);
|
||||
}
|
||||
|
||||
public Rectangle StrokeExtents ()
|
||||
{
|
||||
double x1, y1, x2, y2;
|
||||
NativeMethods.cairo_stroke_extents (state, out x1, out y1, out x2, out y2);
|
||||
NativeMethods.cairo_stroke_extents (handle, out x1, out y1, out x2, out y2);
|
||||
return new Rectangle (x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public void Fill ()
|
||||
{
|
||||
NativeMethods.cairo_fill (state);
|
||||
NativeMethods.cairo_fill (handle);
|
||||
}
|
||||
|
||||
public Rectangle FillExtents ()
|
||||
{
|
||||
double x1, y1, x2, y2;
|
||||
NativeMethods.cairo_fill_extents (state, out x1, out y1, out x2, out y2);
|
||||
NativeMethods.cairo_fill_extents (handle, out x1, out y1, out x2, out y2);
|
||||
return new Rectangle (x1, y1, x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
public void FillPreserve ()
|
||||
{
|
||||
NativeMethods.cairo_fill_preserve (state);
|
||||
NativeMethods.cairo_fill_preserve (handle);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Clip ()
|
||||
{
|
||||
NativeMethods.cairo_clip (state);
|
||||
NativeMethods.cairo_clip (handle);
|
||||
}
|
||||
|
||||
public void ClipPreserve ()
|
||||
{
|
||||
NativeMethods.cairo_clip_preserve (state);
|
||||
NativeMethods.cairo_clip_preserve (handle);
|
||||
}
|
||||
|
||||
public void ResetClip ()
|
||||
{
|
||||
NativeMethods.cairo_reset_clip (state);
|
||||
NativeMethods.cairo_reset_clip (handle);
|
||||
}
|
||||
|
||||
public bool InStroke (double x, double y)
|
||||
{
|
||||
return NativeMethods.cairo_in_stroke (state, x, y);
|
||||
return NativeMethods.cairo_in_stroke (handle, x, y);
|
||||
}
|
||||
|
||||
public bool InClip (double x, double y)
|
||||
{
|
||||
return NativeMethods.cairo_in_clip (state, x, y);
|
||||
return NativeMethods.cairo_in_clip (handle, x, y);
|
||||
}
|
||||
|
||||
public bool InFill (double x, double y)
|
||||
{
|
||||
return NativeMethods.cairo_in_fill (state, x, y);
|
||||
return NativeMethods.cairo_in_fill (handle, x, y);
|
||||
}
|
||||
|
||||
public Pattern PopGroup ()
|
||||
{
|
||||
return Pattern.Lookup (NativeMethods.cairo_pop_group (state));
|
||||
return Pattern.Lookup (NativeMethods.cairo_pop_group (handle), true);
|
||||
}
|
||||
|
||||
public void PopGroupToSource ()
|
||||
{
|
||||
NativeMethods.cairo_pop_group_to_source (state);
|
||||
NativeMethods.cairo_pop_group_to_source (handle);
|
||||
}
|
||||
|
||||
public void PushGroup ()
|
||||
{
|
||||
NativeMethods.cairo_push_group (state);
|
||||
NativeMethods.cairo_push_group (handle);
|
||||
}
|
||||
|
||||
public void PushGroup (Content content)
|
||||
{
|
||||
NativeMethods.cairo_push_group_with_content (state, content);
|
||||
NativeMethods.cairo_push_group_with_content (handle, content);
|
||||
}
|
||||
|
||||
public Surface GroupTarget {
|
||||
get {
|
||||
IntPtr surface = NativeMethods.cairo_get_group_target (state);
|
||||
return Surface.LookupSurface (surface);
|
||||
IntPtr surface = NativeMethods.cairo_get_group_target (handle);
|
||||
return Surface.Lookup (surface, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Rotate (double angle)
|
||||
{
|
||||
NativeMethods.cairo_rotate (state, angle);
|
||||
NativeMethods.cairo_rotate (handle, angle);
|
||||
}
|
||||
|
||||
public void Scale (double sx, double sy)
|
||||
{
|
||||
NativeMethods.cairo_scale (state, sx, sy);
|
||||
NativeMethods.cairo_scale (handle, sx, sy);
|
||||
}
|
||||
|
||||
public void Translate (double tx, double ty)
|
||||
{
|
||||
NativeMethods.cairo_translate (state, tx, ty);
|
||||
NativeMethods.cairo_translate (handle, tx, ty);
|
||||
}
|
||||
|
||||
public void Transform (Matrix m)
|
||||
{
|
||||
NativeMethods.cairo_transform (state, m);
|
||||
NativeMethods.cairo_transform (handle, m);
|
||||
}
|
||||
|
||||
#region Methods that will become obsolete in the long term, after 1.2.5 becomes wildly available
|
||||
|
||||
//[Obsolete("Use UserToDevice instead")]
|
||||
[Obsolete("Use UserToDevice instead")]
|
||||
public void TransformPoint (ref double x, ref double y)
|
||||
{
|
||||
NativeMethods.cairo_user_to_device (state, ref x, ref y);
|
||||
NativeMethods.cairo_user_to_device (handle, ref x, ref y);
|
||||
}
|
||||
|
||||
//[Obsolete("Use UserToDeviceDistance instead")]
|
||||
[Obsolete("Use UserToDeviceDistance instead")]
|
||||
public void TransformDistance (ref double dx, ref double dy)
|
||||
{
|
||||
NativeMethods.cairo_user_to_device_distance (state, ref dx, ref dy);
|
||||
NativeMethods.cairo_user_to_device_distance (handle, ref dx, ref dy);
|
||||
}
|
||||
|
||||
//[Obsolete("Use InverseTransformPoint instead")]
|
||||
[Obsolete("Use DeviceToUser instead")]
|
||||
public void InverseTransformPoint (ref double x, ref double y)
|
||||
{
|
||||
NativeMethods.cairo_device_to_user (state, ref x, ref y);
|
||||
NativeMethods.cairo_device_to_user (handle, ref x, ref y);
|
||||
}
|
||||
|
||||
//[Obsolete("Use DeviceToUserDistance instead")]
|
||||
[Obsolete("Use DeviceToUserDistance instead")]
|
||||
public void InverseTransformDistance (ref double dx, ref double dy)
|
||||
{
|
||||
NativeMethods.cairo_device_to_user_distance (state, ref dx, ref dy);
|
||||
NativeMethods.cairo_device_to_user_distance (handle, ref dx, ref dy);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void UserToDevice (ref double x, ref double y)
|
||||
{
|
||||
NativeMethods.cairo_user_to_device (state, ref x, ref y);
|
||||
NativeMethods.cairo_user_to_device (handle, ref x, ref y);
|
||||
}
|
||||
|
||||
public void UserToDeviceDistance (ref double dx, ref double dy)
|
||||
{
|
||||
NativeMethods.cairo_user_to_device_distance (state, ref dx, ref dy);
|
||||
NativeMethods.cairo_user_to_device_distance (handle, ref dx, ref dy);
|
||||
}
|
||||
|
||||
public void DeviceToUser (ref double x, ref double y)
|
||||
{
|
||||
NativeMethods.cairo_device_to_user (state, ref x, ref y);
|
||||
NativeMethods.cairo_device_to_user (handle, ref x, ref y);
|
||||
}
|
||||
|
||||
public void DeviceToUserDistance (ref double dx, ref double dy)
|
||||
{
|
||||
NativeMethods.cairo_device_to_user_distance (state, ref dx, ref dy);
|
||||
NativeMethods.cairo_device_to_user_distance (handle, ref dx, ref dy);
|
||||
}
|
||||
|
||||
public Cairo.Matrix Matrix {
|
||||
set {
|
||||
NativeMethods.cairo_set_matrix (state, value);
|
||||
NativeMethods.cairo_set_matrix (handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
Matrix m = new Matrix();
|
||||
NativeMethods.cairo_get_matrix (state, m);
|
||||
Matrix m = new Matrix ();
|
||||
NativeMethods.cairo_get_matrix (handle, m);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFontSize (double scale)
|
||||
{
|
||||
NativeMethods.cairo_set_font_size (state, scale);
|
||||
NativeMethods.cairo_set_font_size (handle, scale);
|
||||
}
|
||||
|
||||
public void IdentityMatrix ()
|
||||
{
|
||||
NativeMethods.cairo_identity_matrix (state);
|
||||
NativeMethods.cairo_identity_matrix (handle);
|
||||
}
|
||||
|
||||
[Obsolete ("Use SetFontSize() instead.")]
|
||||
|
@ -801,19 +804,19 @@ namespace Cairo {
|
|||
public Matrix FontMatrix {
|
||||
get {
|
||||
Matrix m;
|
||||
NativeMethods.cairo_get_font_matrix (state, out m);
|
||||
NativeMethods.cairo_get_font_matrix (handle, out m);
|
||||
return m;
|
||||
}
|
||||
set { NativeMethods.cairo_set_font_matrix (state, value); }
|
||||
set { NativeMethods.cairo_set_font_matrix (handle, value); }
|
||||
}
|
||||
|
||||
public FontOptions FontOptions {
|
||||
get {
|
||||
FontOptions options = new FontOptions ();
|
||||
NativeMethods.cairo_get_font_options (state, options.Handle);
|
||||
NativeMethods.cairo_get_font_options (handle, options.Handle);
|
||||
return options;
|
||||
}
|
||||
set { NativeMethods.cairo_set_font_options (state, value.Handle); }
|
||||
set { NativeMethods.cairo_set_font_options (handle, value.Handle); }
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
@ -858,7 +861,7 @@ namespace Cairo {
|
|||
|
||||
ptr = FromGlyphToUnManagedMemory (glyphs);
|
||||
|
||||
NativeMethods.cairo_show_glyphs (state, ptr, glyphs.Length);
|
||||
NativeMethods.cairo_show_glyphs (handle, ptr, glyphs.Length);
|
||||
|
||||
Marshal.FreeHGlobal (ptr);
|
||||
}
|
||||
|
@ -881,7 +884,7 @@ namespace Cairo {
|
|||
|
||||
ptr = FromGlyphToUnManagedMemory (glyphs);
|
||||
|
||||
NativeMethods.cairo_glyph_path (state, ptr, glyphs.Length);
|
||||
NativeMethods.cairo_glyph_path (handle, ptr, glyphs.Length);
|
||||
|
||||
Marshal.FreeHGlobal (ptr);
|
||||
|
||||
|
@ -890,14 +893,14 @@ namespace Cairo {
|
|||
public FontExtents FontExtents {
|
||||
get {
|
||||
FontExtents f_extents;
|
||||
NativeMethods.cairo_font_extents (state, out f_extents);
|
||||
NativeMethods.cairo_font_extents (handle, out f_extents);
|
||||
return f_extents;
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyPage ()
|
||||
{
|
||||
NativeMethods.cairo_copy_page (state);
|
||||
NativeMethods.cairo_copy_page (handle);
|
||||
}
|
||||
|
||||
[Obsolete ("Use SelectFontFace() instead.")]
|
||||
|
@ -908,38 +911,38 @@ namespace Cairo {
|
|||
|
||||
public FontFace ContextFontFace {
|
||||
get {
|
||||
return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (state));
|
||||
return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (handle), false);
|
||||
}
|
||||
|
||||
set {
|
||||
NativeMethods.cairo_set_font_face (state, value == null ? IntPtr.Zero : value.Handle);
|
||||
NativeMethods.cairo_set_font_face (handle, value == null ? IntPtr.Zero : value.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectFontFace (string family, FontSlant slant, FontWeight weight)
|
||||
{
|
||||
NativeMethods.cairo_select_font_face (state, family, slant, weight);
|
||||
NativeMethods.cairo_select_font_face (handle, family, slant, weight);
|
||||
}
|
||||
|
||||
public void ShowPage ()
|
||||
{
|
||||
NativeMethods.cairo_show_page (state);
|
||||
NativeMethods.cairo_show_page (handle);
|
||||
}
|
||||
|
||||
public void ShowText (string str)
|
||||
{
|
||||
NativeMethods.cairo_show_text (state, str);
|
||||
NativeMethods.cairo_show_text (handle, str);
|
||||
}
|
||||
|
||||
public void TextPath (string str)
|
||||
{
|
||||
NativeMethods.cairo_text_path (state, str);
|
||||
NativeMethods.cairo_text_path (handle, str);
|
||||
}
|
||||
|
||||
public TextExtents TextExtents (string utf8)
|
||||
{
|
||||
TextExtents extents;
|
||||
NativeMethods.cairo_text_extents (state, utf8, out extents);
|
||||
NativeMethods.cairo_text_extents (handle, utf8, out extents);
|
||||
return extents;
|
||||
}
|
||||
|
||||
|
@ -949,7 +952,7 @@ namespace Cairo {
|
|||
|
||||
TextExtents extents;
|
||||
|
||||
NativeMethods.cairo_glyph_extents (state, ptr, glyphs.Length, out extents);
|
||||
NativeMethods.cairo_glyph_extents (handle, ptr, glyphs.Length, out extents);
|
||||
|
||||
Marshal.FreeHGlobal (ptr);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,14 +38,11 @@ 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 ()
|
||||
|
@ -71,10 +68,16 @@ namespace Cairo
|
|||
handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
@ -34,9 +34,8 @@ namespace Cairo
|
|||
{
|
||||
IntPtr handle;
|
||||
|
||||
public FontOptions ()
|
||||
public FontOptions () : this (NativeMethods.cairo_font_options_create ())
|
||||
{
|
||||
handle = NativeMethods.cairo_font_options_create ();
|
||||
}
|
||||
|
||||
~FontOptions ()
|
||||
|
@ -59,7 +58,7 @@ namespace Cairo
|
|||
[Obsolete ("Use Dispose()")]
|
||||
public void Destroy ()
|
||||
{
|
||||
Dispose ();
|
||||
NativeMethods.cairo_font_options_destroy (handle);
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,10 +33,11 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,53 +44,42 @@ namespace Cairo {
|
|||
}
|
||||
|
||||
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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ 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 {
|
||||
|
@ -47,14 +47,13 @@ namespace Cairo {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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_dsc_begin_page_setup (surface);
|
||||
NativeMethods.cairo_ps_surface_dsc_begin_page_setup (Handle);
|
||||
}
|
||||
|
||||
public void BeginSetup ()
|
||||
{
|
||||
NativeMethods.cairo_ps_surface_dsc_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Cairo {
|
|||
|
||||
public class Path : IDisposable
|
||||
{
|
||||
internal IntPtr handle = IntPtr.Zero;
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
|
||||
internal Path (IntPtr handle)
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ namespace Cairo {
|
|||
Dispose (false);
|
||||
}
|
||||
|
||||
public IntPtr Handle { get { return handle; } }
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
|
@ -62,7 +63,7 @@ namespace Cairo {
|
|||
if (!disposing || CairoDebug.Enabled)
|
||||
CairoDebug.OnDisposed<Path> (handle, disposing);
|
||||
|
||||
if (!disposing|| handle == IntPtr.Zero)
|
||||
if (!disposing || handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
NativeMethods.cairo_path_destroy (handle);
|
||||
|
|
|
@ -34,45 +34,39 @@ namespace Cairo {
|
|||
|
||||
public class Pattern : IDisposable
|
||||
{
|
||||
[Obsolete]
|
||||
protected IntPtr pattern = IntPtr.Zero;
|
||||
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
protected Pattern ()
|
||||
{
|
||||
}
|
||||
|
||||
static Hashtable patterns = new Hashtable ();
|
||||
|
||||
internal Pattern (IntPtr handle)
|
||||
internal Pattern (IntPtr handle, bool owned)
|
||||
{
|
||||
lock (patterns){
|
||||
patterns [handle] = this;
|
||||
}
|
||||
|
||||
Handle = handle;
|
||||
if (!owned)
|
||||
NativeMethods.cairo_pattern_reference (handle);
|
||||
if (CairoDebug.Enabled)
|
||||
CairoDebug.OnAllocated (handle);
|
||||
}
|
||||
|
@ -84,10 +78,11 @@ namespace Cairo {
|
|||
|
||||
[Obsolete ("Use the SurfacePattern constructor")]
|
||||
public Pattern (Surface surface)
|
||||
: this ( NativeMethods.cairo_pattern_create_for_surface (surface.Handle), true)
|
||||
{
|
||||
pattern = NativeMethods.cairo_pattern_create_for_surface (surface.Handle);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
protected void Reference ()
|
||||
{
|
||||
NativeMethods.cairo_pattern_reference (pattern);
|
||||
|
@ -109,51 +104,51 @@ namespace Cairo {
|
|||
|
||||
NativeMethods.cairo_pattern_destroy (Handle);
|
||||
Handle = IntPtr.Zero;
|
||||
lock (patterns){
|
||||
patterns.Remove (this);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete ("Use Dispose()")]
|
||||
public void Destroy ()
|
||||
{
|
||||
NativeMethods.cairo_pattern_destroy (pattern);
|
||||
}
|
||||
|
||||
public Extend Extend {
|
||||
get { return NativeMethods.cairo_pattern_get_extend (pattern); }
|
||||
set { NativeMethods.cairo_pattern_set_extend (pattern, value); }
|
||||
Dispose ();
|
||||
}
|
||||
|
||||
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 (Handle); }
|
||||
set { NativeMethods.cairo_pattern_set_extend (Handle, value); }
|
||||
}
|
||||
|
||||
public Matrix Matrix {
|
||||
set {
|
||||
NativeMethods.cairo_pattern_set_matrix (pattern, value);
|
||||
NativeMethods.cairo_pattern_set_matrix (Handle, value);
|
||||
}
|
||||
|
||||
get {
|
||||
Matrix m = new Matrix ();
|
||||
NativeMethods.cairo_pattern_get_matrix (pattern, m);
|
||||
NativeMethods.cairo_pattern_get_matrix (Handle, m);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable 612
|
||||
public IntPtr Handle {
|
||||
get { return pattern; }
|
||||
private set { pattern = value; }
|
||||
}
|
||||
#pragma warning restore 612
|
||||
|
||||
[Obsolete ("Replaced by Handle property")]
|
||||
[Obsolete]
|
||||
public IntPtr Pointer {
|
||||
get { return Handle; }
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,17 @@ 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))
|
||||
: this (NativeMethods.cairo_scaled_font_create (fontFace.Handle, matrix, ctm, options.Handle), true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -111,6 +113,7 @@ namespace Cairo {
|
|||
handle = IntPtr.Zero;
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
protected void Reference ()
|
||||
{
|
||||
NativeMethods.cairo_scaled_font_reference (handle);
|
||||
|
|
|
@ -33,38 +33,37 @@ 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 {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
102
cairo/Surface.cs
102
cairo/Surface.cs
|
@ -40,63 +40,54 @@ namespace Cairo {
|
|||
|
||||
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)
|
||||
[Obsolete]
|
||||
protected Surface (IntPtr ptr) : this (ptr, true)
|
||||
{
|
||||
surface = ptr;
|
||||
lock (surfaces.SyncRoot){
|
||||
surfaces [ptr] = this;
|
||||
}
|
||||
if (!owns)
|
||||
NativeMethods.cairo_surface_reference (ptr);
|
||||
|
||||
protected Surface (IntPtr handle, bool owner)
|
||||
{
|
||||
this.handle = handle;
|
||||
if (!owner)
|
||||
NativeMethods.cairo_surface_reference (handle);
|
||||
if (CairoDebug.Enabled)
|
||||
CairoDebug.OnAllocated (ptr);
|
||||
CairoDebug.OnAllocated (handle);
|
||||
}
|
||||
|
||||
static internal Surface LookupExternalSurface (IntPtr p)
|
||||
{
|
||||
lock (surfaces.SyncRoot){
|
||||
object o = surfaces [p];
|
||||
if (o == null){
|
||||
return new Surface (p, false);
|
||||
}
|
||||
return (Surface) o;
|
||||
}
|
||||
}
|
||||
|
||||
public static Surface LookupSurface (IntPtr surface)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +129,7 @@ namespace Cairo {
|
|||
//[Obsolete ("Use Context.SetSource() followed by Context.Paint()")]
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -151,27 +142,24 @@ namespace Cairo {
|
|||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (!disposing || CairoDebug.Enabled)
|
||||
CairoDebug.OnDisposed<Surface> (surface, disposing);
|
||||
CairoDebug.OnDisposed<Surface> (handle, disposing);
|
||||
|
||||
if (!disposing|| surface == IntPtr.Zero)
|
||||
if (!disposing || handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
lock (surfaces.SyncRoot)
|
||||
surfaces.Remove (surface);
|
||||
|
||||
NativeMethods.cairo_surface_destroy (surface);
|
||||
surface = IntPtr.Zero;
|
||||
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 ()
|
||||
|
@ -186,65 +174,59 @@ namespace Cairo {
|
|||
|
||||
public IntPtr Handle {
|
||||
get {
|
||||
return surface;
|
||||
}
|
||||
}
|
||||
|
||||
public Device Device {
|
||||
get {
|
||||
IntPtr dev = NativeMethods.cairo_surface_get_device (surface);
|
||||
return dev == IntPtr.Zero ? null : new Device (dev);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete ("Use Dispose()")]
|
||||
public void Destroy()
|
||||
{
|
||||
Dispose (true);
|
||||
Dispose ();
|
||||
}
|
||||
|
||||
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;
|
||||
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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,18 +33,18 @@ 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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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); }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
<symbol type="manual" cname="cairo_font_options_t" name="Cairo.FontOptions"/>
|
||||
<symbol type="manual" cname="cairo_region_t" name="Cairo.Region"/>
|
||||
<symbol type="marshal" cname="cairo_pattern_t" name="Cairo.Pattern" marshal_type="IntPtr" call_fmt="{0}.Handle" from_fmt="Cairo.Pattern.Lookup ({0})" />
|
||||
<symbol type="marshal" cname="cairo_surface_t" name="Cairo.Surface" marshal_type="IntPtr" call_fmt="{0}.Handle" from_fmt="Cairo.Surface.LookupSurface ({0})" />
|
||||
<symbol type="marshal" cname="cairo_surface_t" name="Cairo.Surface" marshal_type="IntPtr" call_fmt="{0}.Handle" from_fmt="Cairo.Surface.Lookup ({0}, true)" />
|
||||
</api>
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Gdk {
|
|||
public Cairo.Pattern BackgroundPattern {
|
||||
get {
|
||||
IntPtr raw_ret = gdk_window_get_background_pattern(Handle);
|
||||
Cairo.Pattern ret = Cairo.Pattern.Lookup (raw_ret);
|
||||
Cairo.Pattern ret = Cairo.Pattern.Lookup (raw_ret, true);
|
||||
return ret;
|
||||
}
|
||||
set {
|
||||
|
|
Loading…
Reference in a new issue