1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
12 /// <summary>Native surfaces usually bound to an externally-managed buffer.
13 /// The attached <see cref="Efl.Canvas.Surface.NativeBuffer"/> is entirely platform-dependent, which means some of this mixin's subclasses will not work (constructor returns <c>null</c>) on some platforms. This class is meant to be used from native code only (C or C++), with direct access to the display system or a buffer allocation system.</summary>
14 [Efl.Canvas.Surface.NativeMethods]
15 public abstract class Surface : Efl.Canvas.ImageInternal, Efl.Eo.IWrapper
17 ///<summary>Pointer to the native class description.</summary>
18 public override System.IntPtr NativeClass
22 if (((object)this).GetType() == typeof(Surface))
24 return GetEflClassStatic();
28 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
33 [System.Runtime.InteropServices.DllImport(efl.Libs.Evas)] internal static extern System.IntPtr
34 efl_canvas_surface_class_get();
35 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.</summary>
36 /// <param name="parent">Parent instance.</param>
37 public Surface(Efl.Object parent= null
38 ) : base(efl_canvas_surface_class_get(), typeof(Surface), parent)
40 FinishInstantiation();
43 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.
44 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
45 /// <param name="raw">The native pointer to be wrapped.</param>
46 protected Surface(System.IntPtr raw) : base(raw)
50 [Efl.Eo.PrivateNativeClass]
51 private class SurfaceRealized : Surface
53 private SurfaceRealized(IntPtr ptr) : base(ptr)
57 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.
58 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
59 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
60 /// <param name="managedType">The managed type of the public constructor that originated this call.</param>
61 /// <param name="parent">The Efl.Object parent of this instance.</param>
62 protected Surface(IntPtr baseKlass, System.Type managedType, Efl.Object parent) : base(baseKlass, managedType, parent)
66 /// <summary>Verifies if the given object is equal to this one.</summary>
67 /// <param name="instance">The object to compare to.</param>
68 /// <returns>True if both objects point to the same native object.</returns>
69 public override bool Equals(object instance)
71 var other = instance as Efl.Object;
76 return this.NativeHandle == other.NativeHandle;
79 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
80 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
81 public override int GetHashCode()
83 return this.NativeHandle.ToInt32();
86 /// <summary>Turns the native pointer into a string representation.</summary>
87 /// <returns>A string with the type and the native pointer for this object.</returns>
88 public override String ToString()
90 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
93 /// <summary>External buffer attached to this native surface.
94 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
95 /// <returns>The external buffer, depends on its type.</returns>
96 virtual public System.IntPtr GetNativeBuffer() {
97 var _ret_var = Efl.Canvas.Surface.NativeMethods.efl_canvas_surface_native_buffer_get_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle));
98 Eina.Error.RaiseIfUnhandledException();
101 /// <summary>Set the buffer. If this fails, this function returns <c>false</c>, and the surface is left without any attached buffer.</summary>
102 /// <param name="buffer">The external buffer, depends on its type.</param>
103 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
104 virtual public bool SetNativeBuffer(System.IntPtr buffer) {
105 var _ret_var = Efl.Canvas.Surface.NativeMethods.efl_canvas_surface_native_buffer_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle),buffer);
106 Eina.Error.RaiseIfUnhandledException();
109 /// <summary>External buffer attached to this native surface.
110 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
111 /// <value>The external buffer, depends on its type.</value>
112 public System.IntPtr NativeBuffer {
113 get { return GetNativeBuffer(); }
114 set { SetNativeBuffer(value); }
116 private static IntPtr GetEflClassStatic()
118 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
120 /// <summary>Wrapper for native methods and virtual method delegates.
121 /// For internal use by generated code only.</summary>
122 public new class NativeMethods : Efl.Canvas.ImageInternal.NativeMethods
124 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Evas);
125 /// <summary>Gets the list of Eo operations to override.</summary>
126 /// <returns>The list of Eo operations to be overload.</returns>
127 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
129 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
130 var methods = Efl.Eo.Globals.GetUserMethods(type);
132 if (efl_canvas_surface_native_buffer_get_static_delegate == null)
134 efl_canvas_surface_native_buffer_get_static_delegate = new efl_canvas_surface_native_buffer_get_delegate(native_buffer_get);
137 if (methods.FirstOrDefault(m => m.Name == "GetNativeBuffer") != null)
139 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_canvas_surface_native_buffer_get"), func = Marshal.GetFunctionPointerForDelegate(efl_canvas_surface_native_buffer_get_static_delegate) });
142 if (efl_canvas_surface_native_buffer_set_static_delegate == null)
144 efl_canvas_surface_native_buffer_set_static_delegate = new efl_canvas_surface_native_buffer_set_delegate(native_buffer_set);
147 if (methods.FirstOrDefault(m => m.Name == "SetNativeBuffer") != null)
149 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_canvas_surface_native_buffer_set"), func = Marshal.GetFunctionPointerForDelegate(efl_canvas_surface_native_buffer_set_static_delegate) });
152 descs.AddRange(base.GetEoOps(type));
155 /// <summary>Returns the Eo class for the native methods of this class.</summary>
156 /// <returns>The native class pointer.</returns>
157 public override IntPtr GetEflClass()
159 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
162 #pragma warning disable CA1707, SA1300, SA1600
165 private delegate System.IntPtr efl_canvas_surface_native_buffer_get_delegate(System.IntPtr obj, System.IntPtr pd);
168 public delegate System.IntPtr efl_canvas_surface_native_buffer_get_api_delegate(System.IntPtr obj);
170 public static Efl.Eo.FunctionWrapper<efl_canvas_surface_native_buffer_get_api_delegate> efl_canvas_surface_native_buffer_get_ptr = new Efl.Eo.FunctionWrapper<efl_canvas_surface_native_buffer_get_api_delegate>(Module, "efl_canvas_surface_native_buffer_get");
172 private static System.IntPtr native_buffer_get(System.IntPtr obj, System.IntPtr pd)
174 Eina.Log.Debug("function efl_canvas_surface_native_buffer_get was called");
175 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
178 System.IntPtr _ret_var = default(System.IntPtr);
181 _ret_var = ((Surface)wrapper).GetNativeBuffer();
185 Eina.Log.Warning($"Callback error: {e.ToString()}");
186 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
194 return efl_canvas_surface_native_buffer_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
198 private static efl_canvas_surface_native_buffer_get_delegate efl_canvas_surface_native_buffer_get_static_delegate;
200 [return: MarshalAs(UnmanagedType.U1)]
201 private delegate bool efl_canvas_surface_native_buffer_set_delegate(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer);
203 [return: MarshalAs(UnmanagedType.U1)]
204 public delegate bool efl_canvas_surface_native_buffer_set_api_delegate(System.IntPtr obj, System.IntPtr buffer);
206 public static Efl.Eo.FunctionWrapper<efl_canvas_surface_native_buffer_set_api_delegate> efl_canvas_surface_native_buffer_set_ptr = new Efl.Eo.FunctionWrapper<efl_canvas_surface_native_buffer_set_api_delegate>(Module, "efl_canvas_surface_native_buffer_set");
208 private static bool native_buffer_set(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer)
210 Eina.Log.Debug("function efl_canvas_surface_native_buffer_set was called");
211 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
214 bool _ret_var = default(bool);
217 _ret_var = ((Surface)wrapper).SetNativeBuffer(buffer);
221 Eina.Log.Warning($"Callback error: {e.ToString()}");
222 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
230 return efl_canvas_surface_native_buffer_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), buffer);
234 private static efl_canvas_surface_native_buffer_set_delegate efl_canvas_surface_native_buffer_set_static_delegate;
236 #pragma warning restore CA1707, SA1300, SA1600