2 #pragma warning disable CS1591
4 using System.Runtime.InteropServices;
5 using System.Collections.Generic;
7 using System.Threading;
8 using System.ComponentModel;
13 /// <summary>Native surfaces usually bound to an externally-managed buffer.
14 /// 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>
15 /// <remarks>This is a <b>BETA</b> class. It can be modified or removed in the future. Do not use it for product development.</remarks>
16 [Efl.Canvas.Surface.NativeMethods]
17 [Efl.Eo.BindingEntity]
18 public abstract class Surface : Efl.Canvas.ImageInternal
20 /// <summary>Pointer to the native class description.</summary>
21 public override System.IntPtr NativeClass
25 if (((object)this).GetType() == typeof(Surface))
27 return GetEflClassStatic();
31 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
36 [System.Runtime.InteropServices.DllImport(efl.Libs.Evas)] internal static extern System.IntPtr
37 efl_canvas_surface_class_get();
38 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.</summary>
39 /// <param name="parent">Parent instance.</param>
40 public Surface(Efl.Object parent= null
41 ) : base(efl_canvas_surface_class_get(), parent)
43 FinishInstantiation();
46 /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code.
47 /// Do not call this constructor directly.</summary>
48 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
49 protected Surface(ConstructingHandle ch) : base(ch)
53 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.
54 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
55 /// <param name="wh">The native pointer to be wrapped.</param>
56 protected Surface(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
60 [Efl.Eo.PrivateNativeClass]
61 private class SurfaceRealized : Surface
63 private SurfaceRealized(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
67 /// <summary>Initializes a new instance of the <see cref="Surface"/> class.
68 /// Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
69 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
70 /// <param name="parent">The Efl.Object parent of this instance.</param>
71 protected Surface(IntPtr baseKlass, Efl.Object parent) : base(baseKlass, parent)
75 /// <summary>External buffer attached to this native surface.
76 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
77 /// <returns>The external buffer, depends on its type.</returns>
78 virtual public System.IntPtr GetNativeBuffer() {
79 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)));
80 Eina.Error.RaiseIfUnhandledException();
83 /// <summary>Set the buffer. If this fails, this function returns <c>false</c>, and the surface is left without any attached buffer.</summary>
84 /// <param name="buffer">The external buffer, depends on its type.</param>
85 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
86 virtual public bool SetNativeBuffer(System.IntPtr buffer) {
87 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);
88 Eina.Error.RaiseIfUnhandledException();
91 /// <summary>External buffer attached to this native surface.
92 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
93 /// <value>The external buffer, depends on its type.</value>
94 public System.IntPtr NativeBuffer {
95 get { return GetNativeBuffer(); }
96 set { SetNativeBuffer(value); }
98 private static IntPtr GetEflClassStatic()
100 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
102 /// <summary>Wrapper for native methods and virtual method delegates.
103 /// For internal use by generated code only.</summary>
104 public new class NativeMethods : Efl.Canvas.ImageInternal.NativeMethods
106 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Evas);
107 /// <summary>Gets the list of Eo operations to override.</summary>
108 /// <returns>The list of Eo operations to be overload.</returns>
109 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
111 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
112 var methods = Efl.Eo.Globals.GetUserMethods(type);
114 if (efl_canvas_surface_native_buffer_get_static_delegate == null)
116 efl_canvas_surface_native_buffer_get_static_delegate = new efl_canvas_surface_native_buffer_get_delegate(native_buffer_get);
119 if (methods.FirstOrDefault(m => m.Name == "GetNativeBuffer") != null)
121 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) });
124 if (efl_canvas_surface_native_buffer_set_static_delegate == null)
126 efl_canvas_surface_native_buffer_set_static_delegate = new efl_canvas_surface_native_buffer_set_delegate(native_buffer_set);
129 if (methods.FirstOrDefault(m => m.Name == "SetNativeBuffer") != null)
131 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) });
134 descs.AddRange(base.GetEoOps(type));
137 /// <summary>Returns the Eo class for the native methods of this class.</summary>
138 /// <returns>The native class pointer.</returns>
139 public override IntPtr GetEflClass()
141 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
144 #pragma warning disable CA1707, CS1591, SA1300, SA1600
147 private delegate System.IntPtr efl_canvas_surface_native_buffer_get_delegate(System.IntPtr obj, System.IntPtr pd);
150 public delegate System.IntPtr efl_canvas_surface_native_buffer_get_api_delegate(System.IntPtr obj);
152 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");
154 private static System.IntPtr native_buffer_get(System.IntPtr obj, System.IntPtr pd)
156 Eina.Log.Debug("function efl_canvas_surface_native_buffer_get was called");
157 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
160 System.IntPtr _ret_var = default(System.IntPtr);
163 _ret_var = ((Surface)ws.Target).GetNativeBuffer();
167 Eina.Log.Warning($"Callback error: {e.ToString()}");
168 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
176 return efl_canvas_surface_native_buffer_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
180 private static efl_canvas_surface_native_buffer_get_delegate efl_canvas_surface_native_buffer_get_static_delegate;
182 [return: MarshalAs(UnmanagedType.U1)]
183 private delegate bool efl_canvas_surface_native_buffer_set_delegate(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer);
185 [return: MarshalAs(UnmanagedType.U1)]
186 public delegate bool efl_canvas_surface_native_buffer_set_api_delegate(System.IntPtr obj, System.IntPtr buffer);
188 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");
190 private static bool native_buffer_set(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer)
192 Eina.Log.Debug("function efl_canvas_surface_native_buffer_set was called");
193 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
196 bool _ret_var = default(bool);
199 _ret_var = ((Surface)ws.Target).SetNativeBuffer(buffer);
203 Eina.Log.Warning($"Callback error: {e.ToString()}");
204 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
212 return efl_canvas_surface_native_buffer_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), buffer);
216 private static efl_canvas_surface_native_buffer_set_delegate efl_canvas_surface_native_buffer_set_static_delegate;
218 #pragma warning restore CA1707, CS1591, SA1300, SA1600
227 #pragma warning disable CS1591
228 public static class Efl_CanvasSurface_ExtensionMethods {
229 public static Efl.BindableProperty<System.IntPtr> NativeBuffer<T>(this Efl.Ui.ItemFactory<T> fac, Efl.Csharp.ExtensionTag<Efl.Canvas.Surface, T>magic = null) where T : Efl.Canvas.Surface {
230 return new Efl.BindableProperty<System.IntPtr>("native_buffer", fac);
234 #pragma warning restore CS1591