[NUI](Rendering) Create Renderer constructor without Geometry and Shader
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 7 Mar 2025 01:41:40 +0000 (10:41 +0900)
committerWonsik Jung <sidein@samsung.com>
Wed, 12 Mar 2025 04:26:52 +0000 (13:26 +0900)
Until now, geometry and shader was mendentory.
But if developper try to derive the class, this give some bad experience.

So let we allow to create renderer without geometry or shader.

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.Renderer.cs
src/Tizen.NUI/src/public/Rendering/Renderer.cs

index ee457c34dbccfad16bd5eb00630f5ca2fb57b09b..3e8fe5a7bf54722bc1d74cccf32b7a10e5ea13c1 100755 (executable)
@@ -111,6 +111,9 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Renderer_New")]
             public static extern global::System.IntPtr New(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Renderer_NewWithoutGeometryAndShader")]
+            public static extern global::System.IntPtr New();
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_Renderer")]
             public static extern void DeleteRenderer(global::System.Runtime.InteropServices.HandleRef jarg1);
 
index f6a6441e8082d27fc615b0ffa395eb9d85b39313..53c7de2727b92603e19e5cc5ca6c48a7515da253 100755 (executable)
@@ -39,7 +39,16 @@ namespace Tizen.NUI
             CurrentGeometry = geometry;
             CurrentShader = shader;
 
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            NDalicPINVOKE.ThrowExceptionIfExists();
+        }
+
+        /// <summary>
+        /// Create an instance of Renderer without Geometry or Shader.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Renderer() : this(Interop.Renderer.New(), true)
+        {
+            NDalicPINVOKE.ThrowExceptionIfExists();
         }
 
         /// <summary>
@@ -805,6 +814,35 @@ namespace Tizen.NUI
         {
         }
 
+        /// <summary>
+        /// you can override it to clean-up your own resources.
+        /// </summary>
+        /// <param name="type">DisposeTypes</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void Dispose(DisposeTypes type)
+        {
+            if (Disposed)
+            {
+                return;
+            }
+
+            if (type == DisposeTypes.Explicit)
+            {
+                //Called by User
+                //Release your own managed resources here.
+                //You should release all of your own disposable objects here.
+
+                CurrentGeometry = null;
+                CurrentShader = null;
+            }
+
+            //Release your own unmanaged resources here.
+            //You should not access any managed member here except static instance.
+            //because the execution order of Finalizes is non-deterministic.
+
+            base.Dispose(type);
+        }
+
         /// This will not be public opened.
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)