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 [Efl.Eo.BindingEntity]
16 public abstract class Surface : Efl.Canvas.ImageInternal
18 ///<summary>Pointer to the native class description.</summary>
19 public override System.IntPtr NativeClass
23 if (((object)this).GetType() == typeof(Surface))
25 return GetEflClassStatic();
29 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
34 [System.Runtime.InteropServices.DllImport(efl.Libs.Evas)] internal static extern System.IntPtr
35 efl_canvas_surface_class_get();
36 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.</summary>
37 /// <param name="parent">Parent instance.</param>
38 public Surface(Efl.Object parent= null
39 ) : base(efl_canvas_surface_class_get(), parent)
41 FinishInstantiation();
44 /// <summary>Constructor to be used when objects are expected to be constructed from native code.</summary>
45 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
46 protected Surface(ConstructingHandle ch) : base(ch)
50 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.
51 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
52 /// <param name="wh">The native pointer to be wrapped.</param>
53 protected Surface(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
57 [Efl.Eo.PrivateNativeClass]
58 private class SurfaceRealized : Surface
60 private SurfaceRealized(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
64 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.
65 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
66 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
67 /// <param name="parent">The Efl.Object parent of this instance.</param>
68 protected Surface(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)
72 /// <summary>External buffer attached to this native surface.
73 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
74 /// <returns>The external buffer, depends on its type.</returns>
75 virtual public System.IntPtr GetNativeBuffer() {
76 var _ret_var = Efl.Canvas.Surface.NativeMethods.efl_canvas_surface_native_buffer_get_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)));
77 Eina.Error.RaiseIfUnhandledException();
80 /// <summary>Set the buffer. If this fails, this function returns <c>false</c>, and the surface is left without any attached buffer.</summary>
81 /// <param name="buffer">The external buffer, depends on its type.</param>
82 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
83 virtual public bool SetNativeBuffer(System.IntPtr buffer) {
84 var _ret_var = Efl.Canvas.Surface.NativeMethods.efl_canvas_surface_native_buffer_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)),buffer);
85 Eina.Error.RaiseIfUnhandledException();
88 /// <summary>External buffer attached to this native surface.
89 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
90 /// <value>The external buffer, depends on its type.</value>
91 public System.IntPtr NativeBuffer {
92 get { return GetNativeBuffer(); }
93 set { SetNativeBuffer(value); }
95 private static IntPtr GetEflClassStatic()
97 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
99 /// <summary>Wrapper for native methods and virtual method delegates.
100 /// For internal use by generated code only.</summary>
101 public new class NativeMethods : Efl.Canvas.ImageInternal.NativeMethods
103 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Evas);
104 /// <summary>Gets the list of Eo operations to override.</summary>
105 /// <returns>The list of Eo operations to be overload.</returns>
106 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
108 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
109 var methods = Efl.Eo.Globals.GetUserMethods(type);
111 if (efl_canvas_surface_native_buffer_get_static_delegate == null)
113 efl_canvas_surface_native_buffer_get_static_delegate = new efl_canvas_surface_native_buffer_get_delegate(native_buffer_get);
116 if (methods.FirstOrDefault(m => m.Name == "GetNativeBuffer") != null)
118 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) });
121 if (efl_canvas_surface_native_buffer_set_static_delegate == null)
123 efl_canvas_surface_native_buffer_set_static_delegate = new efl_canvas_surface_native_buffer_set_delegate(native_buffer_set);
126 if (methods.FirstOrDefault(m => m.Name == "SetNativeBuffer") != null)
128 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) });
131 descs.AddRange(base.GetEoOps(type));
134 /// <summary>Returns the Eo class for the native methods of this class.</summary>
135 /// <returns>The native class pointer.</returns>
136 public override IntPtr GetEflClass()
138 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
141 #pragma warning disable CA1707, CS1591, SA1300, SA1600
144 private delegate System.IntPtr efl_canvas_surface_native_buffer_get_delegate(System.IntPtr obj, System.IntPtr pd);
147 public delegate System.IntPtr efl_canvas_surface_native_buffer_get_api_delegate(System.IntPtr obj);
149 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");
151 private static System.IntPtr native_buffer_get(System.IntPtr obj, System.IntPtr pd)
153 Eina.Log.Debug("function efl_canvas_surface_native_buffer_get was called");
154 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
157 System.IntPtr _ret_var = default(System.IntPtr);
160 _ret_var = ((Surface)ws.Target).GetNativeBuffer();
164 Eina.Log.Warning($"Callback error: {e.ToString()}");
165 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
173 return efl_canvas_surface_native_buffer_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
177 private static efl_canvas_surface_native_buffer_get_delegate efl_canvas_surface_native_buffer_get_static_delegate;
179 [return: MarshalAs(UnmanagedType.U1)]
180 private delegate bool efl_canvas_surface_native_buffer_set_delegate(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer);
182 [return: MarshalAs(UnmanagedType.U1)]
183 public delegate bool efl_canvas_surface_native_buffer_set_api_delegate(System.IntPtr obj, System.IntPtr buffer);
185 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");
187 private static bool native_buffer_set(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer)
189 Eina.Log.Debug("function efl_canvas_surface_native_buffer_set was called");
190 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
193 bool _ret_var = default(bool);
196 _ret_var = ((Surface)ws.Target).SetNativeBuffer(buffer);
200 Eina.Log.Warning($"Callback error: {e.ToString()}");
201 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
209 return efl_canvas_surface_native_buffer_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), buffer);
213 private static efl_canvas_surface_native_buffer_set_delegate efl_canvas_surface_native_buffer_set_static_delegate;
215 #pragma warning restore CA1707, CS1591, SA1300, SA1600