[NUI] Add ImageUrl
authorSunghyun Kim <scholb.kim@samsung.com>
Mon, 14 Jun 2021 02:55:04 +0000 (11:55 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 9 Jul 2021 10:39:50 +0000 (19:39 +0900)
ImageUrl is a class for wrapping url that is get from external buffer.
it is used for lifecycle management of external buffers.

src/Tizen.NUI/src/internal/Interop/Interop.Capture.cs [changed mode: 0755->0644]
src/Tizen.NUI/src/internal/Interop/Interop.ImageUrl.cs [new file with mode: 0644]
src/Tizen.NUI/src/internal/Interop/Interop.NativeImageSource.cs
src/Tizen.NUI/src/internal/Interop/Interop.PixelData.cs
src/Tizen.NUI/src/internal/WebView/WebHitTestResult.cs
src/Tizen.NUI/src/public/Images/ImageUrl.cs [new file with mode: 0644]
src/Tizen.NUI/src/public/Images/NativeImageSource.cs [changed mode: 0755->0644]
src/Tizen.NUI/src/public/Images/PixelData.cs

old mode 100755 (executable)
new mode 100644 (file)
index 0370953..8c23fe7
@@ -86,7 +86,7 @@ namespace Tizen.NUI
             public static extern IntPtr GetNativeImageSourcePtr(HandleRef jarg1);
 
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GenerateUrl")]
-            public static extern string GenerateUrl(HandleRef capture);
+            public static extern IntPtr GenerateUrl(HandleRef capture);
 
             [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Capture_GetCapturedBuffer")]
             public static extern IntPtr GetCapturedBuffer(HandleRef capture);
diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ImageUrl.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ImageUrl.cs
new file mode 100644 (file)
index 0000000..adec6ae
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Tizen.NUI
+{
+    using global::System;
+    using global::System.Runtime.InteropServices;
+
+    internal static partial class Interop
+    {
+        internal static partial class ImageUrl
+        {
+            [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_ImageUrl")]
+            public static extern void Delete(HandleRef jarg1);
+
+            [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageUrl_Get")]
+            public static extern string GetUrl(HandleRef jarg1);
+        }
+    }
+}
index 6a14e44..a2318c1 100755 (executable)
@@ -42,7 +42,7 @@ namespace Tizen.NUI
             public static extern bool ReleaseBuffer(IntPtr jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_NativeImageSource_GenerateUrl")]
-            public static extern string GenerateUrl(IntPtr handle);
+            public static extern IntPtr GenerateUrl(IntPtr handle);
         }
     }
 }
index 8a50aee..75d424f 100755 (executable)
@@ -49,7 +49,7 @@ namespace Tizen.NUI
             public static extern int GetPixelFormat(global::System.Runtime.InteropServices.HandleRef jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_PixelData_GenerateUrl")]
-            public static extern string GenerateUrl(global::System.IntPtr handle);
+            public static extern global::System.IntPtr GenerateUrl(global::System.IntPtr handle);
         }
     }
 }
index 6cadc00..87d53f5 100755 (executable)
@@ -222,7 +222,8 @@ namespace Tizen.NUI
             {
                 IntPtr bufferIntPtr = Interop.WebHitTest.GetImageBuffer(SwigCPtr);
                 PixelData pixelData = new PixelData(bufferIntPtr, true);
-                ImageView image = new ImageView(pixelData.Url);
+                ImageUrl url = pixelData.GenerateUrl();
+                ImageView image = new ImageView(url.ToString());
                 image.Size = new Size(pixelData.GetWidth(), pixelData.GetHeight());
                 pixelData.Dispose();
                 return image;
diff --git a/src/Tizen.NUI/src/public/Images/ImageUrl.cs b/src/Tizen.NUI/src/public/Images/ImageUrl.cs
new file mode 100644 (file)
index 0000000..120803c
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+    using global::System;
+    using global::System.ComponentModel;
+    using global::System.Runtime.InteropServices;
+    using Tizen.NUI.BaseComponents;
+
+    /// <summary>
+    /// Url for Image
+    /// </summary>
+    /// <remarks>Hidden API: Only for inhouse or developing usage. The behavior and interface can be changed anytime.</remarks>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class ImageUrl : BaseHandle
+    {
+        internal ImageUrl(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+        {
+        }
+
+        /// <summary>
+        /// Dispose
+        /// </summary>
+        /// <param name="type"></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.
+            }
+
+            base.Dispose(type);
+        }
+
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void ReleaseSwigCPtr(HandleRef swigCPtr)
+        {
+            Interop.ImageUrl.Delete(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public override string ToString()
+        {
+            string ret = Interop.ImageUrl.GetUrl(SwigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index 1ec852c..2c4c3e8
@@ -38,18 +38,14 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Get URI from native image source.
+        /// Generate Url from native image source.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public string Url
+        public ImageUrl GenerateUrl()
         {
-            get
-            {
-                string uri = "";
-                uri = Interop.NativeImageSource.GenerateUrl(this.SwigCPtr.Handle);
-                if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
-                return uri;
-            }
+            ImageUrl ret = new ImageUrl(Interop.NativeImageSource.GenerateUrl(this.SwigCPtr.Handle), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
+            return ret;
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
index 251c2c4..a001174 100755 (executable)
@@ -79,18 +79,14 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Get URI from pixel data.
+        /// Generate Url from pixel data.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public string Url
+        public ImageUrl GenerateUrl()
         {
-            get
-            {
-                string Uri = "";
-                Uri = Interop.PixelData.GenerateUrl(this.SwigCPtr.Handle);
-                if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
-                return Uri;
-            }
+            ImageUrl ret = new ImageUrl(Interop.PixelData.GenerateUrl(this.SwigCPtr.Handle), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
+            return ret;
         }
 
         /// <summary>