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
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>External buffer attached to this native surface.
67 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
68 /// <returns>The external buffer, depends on its type.</returns>
69 virtual public System.IntPtr GetNativeBuffer() {
70 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));
71 Eina.Error.RaiseIfUnhandledException();
74 /// <summary>Set the buffer. If this fails, this function returns <c>false</c>, and the surface is left without any attached buffer.</summary>
75 /// <param name="buffer">The external buffer, depends on its type.</param>
76 /// <returns><c>true</c> on success, <c>false</c> otherwise</returns>
77 virtual public bool SetNativeBuffer(System.IntPtr buffer) {
78 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);
79 Eina.Error.RaiseIfUnhandledException();
82 /// <summary>External buffer attached to this native surface.
83 /// Set to <c>null</c> to detach this surface from the external buffer.</summary>
84 /// <value>The external buffer, depends on its type.</value>
85 public System.IntPtr NativeBuffer {
86 get { return GetNativeBuffer(); }
87 set { SetNativeBuffer(value); }
89 private static IntPtr GetEflClassStatic()
91 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
93 /// <summary>Wrapper for native methods and virtual method delegates.
94 /// For internal use by generated code only.</summary>
95 public new class NativeMethods : Efl.Canvas.ImageInternal.NativeMethods
97 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Evas);
98 /// <summary>Gets the list of Eo operations to override.</summary>
99 /// <returns>The list of Eo operations to be overload.</returns>
100 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
102 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
103 var methods = Efl.Eo.Globals.GetUserMethods(type);
105 if (efl_canvas_surface_native_buffer_get_static_delegate == null)
107 efl_canvas_surface_native_buffer_get_static_delegate = new efl_canvas_surface_native_buffer_get_delegate(native_buffer_get);
110 if (methods.FirstOrDefault(m => m.Name == "GetNativeBuffer") != null)
112 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) });
115 if (efl_canvas_surface_native_buffer_set_static_delegate == null)
117 efl_canvas_surface_native_buffer_set_static_delegate = new efl_canvas_surface_native_buffer_set_delegate(native_buffer_set);
120 if (methods.FirstOrDefault(m => m.Name == "SetNativeBuffer") != null)
122 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) });
125 descs.AddRange(base.GetEoOps(type));
128 /// <summary>Returns the Eo class for the native methods of this class.</summary>
129 /// <returns>The native class pointer.</returns>
130 public override IntPtr GetEflClass()
132 return Efl.Canvas.Surface.efl_canvas_surface_class_get();
135 #pragma warning disable CA1707, CS1591, SA1300, SA1600
138 private delegate System.IntPtr efl_canvas_surface_native_buffer_get_delegate(System.IntPtr obj, System.IntPtr pd);
141 public delegate System.IntPtr efl_canvas_surface_native_buffer_get_api_delegate(System.IntPtr obj);
143 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");
145 private static System.IntPtr native_buffer_get(System.IntPtr obj, System.IntPtr pd)
147 Eina.Log.Debug("function efl_canvas_surface_native_buffer_get was called");
148 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
151 System.IntPtr _ret_var = default(System.IntPtr);
154 _ret_var = ((Surface)ws.Target).GetNativeBuffer();
158 Eina.Log.Warning($"Callback error: {e.ToString()}");
159 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
167 return efl_canvas_surface_native_buffer_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
171 private static efl_canvas_surface_native_buffer_get_delegate efl_canvas_surface_native_buffer_get_static_delegate;
173 [return: MarshalAs(UnmanagedType.U1)]
174 private delegate bool efl_canvas_surface_native_buffer_set_delegate(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer);
176 [return: MarshalAs(UnmanagedType.U1)]
177 public delegate bool efl_canvas_surface_native_buffer_set_api_delegate(System.IntPtr obj, System.IntPtr buffer);
179 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");
181 private static bool native_buffer_set(System.IntPtr obj, System.IntPtr pd, System.IntPtr buffer)
183 Eina.Log.Debug("function efl_canvas_surface_native_buffer_set was called");
184 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
187 bool _ret_var = default(bool);
190 _ret_var = ((Surface)ws.Target).SetNativeBuffer(buffer);
194 Eina.Log.Warning($"Callback error: {e.ToString()}");
195 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
203 return efl_canvas_surface_native_buffer_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), buffer);
207 private static efl_canvas_surface_native_buffer_set_delegate efl_canvas_surface_native_buffer_set_static_delegate;
209 #pragma warning restore CA1707, CS1591, SA1300, SA1600