Revert "Remove ReleaseFunction enum at PixelData (#3436)"
authorJunsuChoi <jsuya.choi@samsung.com>
Wed, 25 Aug 2021 02:23:51 +0000 (11:23 +0900)
committerJunsuChoi <junduru019@gmail.com>
Wed, 25 Aug 2021 02:35:16 +0000 (11:35 +0900)
This reverts commit c2951987b9232e1fe24c8d2d98334fbb3ed03327.

src/Tizen.NUI.Wearable/src/public/Title.cs
src/Tizen.NUI/src/internal/Interop/Interop.PixelData.cs
src/Tizen.NUI/src/public/Images/PixelData.cs
test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/Images/TSPixelData.cs

index 5d3fb1e..660198b 100755 (executable)
@@ -270,7 +270,7 @@ namespace Tizen.NUI.Components
             pixelBuffer[6] = (byte)(0xFF * color2.Z);
             pixelBuffer[7] = (byte)(0xFF * color2.W);
 
-            PixelData pixelData = new PixelData(pixelBuffer, size, width, height, PixelFormat.RGBA8888);
+            PixelData pixelData = new PixelData(pixelBuffer, size, width, height, PixelFormat.RGBA8888, PixelData.ReleaseFunction.DeleteArray );
             Texture texture = new Texture(TextureType.TEXTURE_2D, PixelFormat.RGBA8888, width, height);
             texture.Upload(pixelData);
 
index 50813bb..75d424f 100755 (executable)
@@ -25,7 +25,7 @@ namespace Tizen.NUI
             public static extern global::System.IntPtr Upcast(global::System.IntPtr jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PixelData_New")]
-            public static extern global::System.IntPtr New([global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] byte[] jarg1, uint jarg2, uint jarg3, uint jarg4, int jarg5);
+            public static extern global::System.IntPtr New([global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] byte[] jarg1, uint jarg2, uint jarg3, uint jarg4, int jarg5, int jarg6);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_PixelData__SWIG_0")]
             public static extern global::System.IntPtr NewPixelData();
index 6b0ec8f..a001174 100755 (executable)
@@ -45,10 +45,11 @@ namespace Tizen.NUI
         /// <param name="width">Buffer width in pixels.</param>
         /// <param name="height">Buffer height in pixels.</param>
         /// <param name="pixelFormat">The pixel format.</param>
+        /// <param name="releaseFunction">The function used to release the memory.</param>
         /// <since_tizen> 5 </since_tizen>
         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat), true)
+        public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat, PixelData.ReleaseFunction releaseFunction) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat, (int)releaseFunction), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
@@ -59,6 +60,25 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Enumeration for function to release the pixel buffer.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public enum ReleaseFunction
+        {
+            /// <summary>
+            /// Use free function to release the pixel buffer.
+            /// </summary>
+            Free,
+
+            /// <summary>
+            /// Use delete[] operator to release the pixel buffer.
+            /// </summary>
+            DeleteArray
+        }
+
+        /// <summary>
         /// Generate Url from pixel data.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index 27af0d3..e58cf7b 100755 (executable)
@@ -41,7 +41,7 @@ namespace Tizen.NUI.Devel.Tests
 
             byte[] buffer = new byte[1024];
 
-            var testingTarget = new PixelData(buffer, 1024, 100, 150, PixelFormat.L8);
+            var testingTarget = new PixelData(buffer, 1024, 100, 150, PixelFormat.L8, PixelData.ReleaseFunction.Free);
             Assert.IsNotNull(testingTarget, "Can't create success object PixelData");
             Assert.IsInstanceOf<PixelData>(testingTarget, "Should be an instance of PixelData type.");
 
@@ -63,7 +63,7 @@ namespace Tizen.NUI.Devel.Tests
 
             byte[] buffer = new byte[10];
 
-            using (PixelData pixelData = new PixelData(buffer, 10, 1, 2, PixelFormat.L8))
+            using (PixelData pixelData = new PixelData(buffer, 10, 1, 2, PixelFormat.L8, PixelData.ReleaseFunction.Free))
             {
                 var testingTarget = new PixelData(PixelData.getCPtr(pixelData).Handle, true);
                 Assert.IsNotNull(testingTarget, "Can't create success object PixelData");
@@ -89,7 +89,7 @@ namespace Tizen.NUI.Devel.Tests
 
             byte[] buffer = new byte[10];
 
-            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.L8);
+            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.L8, PixelData.ReleaseFunction.Free);
             Assert.IsNotNull(testingTarget, "Can't create success object PixelData");
             Assert.IsInstanceOf<PixelData>(testingTarget, "Should be an instance of PixelData type.");
 
@@ -114,7 +114,7 @@ namespace Tizen.NUI.Devel.Tests
 
             byte[] buffer = new byte[10];
 
-            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.L8);
+            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.L8, PixelData.ReleaseFunction.Free);
             Assert.IsNotNull(testingTarget, "Can't create success object PixelData");
             Assert.IsInstanceOf<PixelData>(testingTarget, "Should be an instance of PixelData type.");
 
@@ -139,7 +139,7 @@ namespace Tizen.NUI.Devel.Tests
 
             byte[] buffer = new byte[10];
 
-            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.L8);
+            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.L8, PixelData.ReleaseFunction.Free);
             Assert.IsNotNull(testingTarget, "Can't create success object PixelData");
             Assert.IsInstanceOf<PixelData>(testingTarget, "Should be an instance of PixelData type.");
 
@@ -164,7 +164,7 @@ namespace Tizen.NUI.Devel.Tests
 
             byte[] buffer = new byte[10];
 
-            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.BGR8888);
+            var testingTarget = new PixelData(buffer, 10, 1, 2, PixelFormat.BGR8888, PixelData.ReleaseFunction.Free);
             Assert.IsNotNull(testingTarget, "Can't create success object PixelData");
             Assert.IsInstanceOf<PixelData>(testingTarget, "Should be an instance of PixelData type.");