[NUI] Introduce MaskEffect (#6905)
authorChihun Jeong <50663828+ANZ1217@users.noreply.github.com>
Tue, 13 May 2025 04:07:39 +0000 (13:07 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 14 May 2025 06:35:12 +0000 (15:35 +0900)
Co-authored-by: ANZ1217 <chihun.jeong@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.MaskEffect.cs [new file with mode: 0644]
src/Tizen.NUI/src/public/RenderEffects/RenderEffect.cs

diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.MaskEffect.cs b/src/Tizen.NUI/src/internal/Interop/Interop.MaskEffect.cs
new file mode 100644 (file)
index 0000000..fdb030b
--- /dev/null
@@ -0,0 +1,13 @@
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+        internal static partial class MaskEffect
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MaskEffect_New__SWIG_0")]
+            public static extern global::System.IntPtr New(global::System.Runtime.InteropServices.HandleRef control);
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_MaskEffect_New__SWIG_1")]
+            public static extern global::System.IntPtr New(global::System.Runtime.InteropServices.HandleRef control, MaskEffectMode maskMode, float positionX, float positionY, float scaleX, float scaleY);
+        }
+    }
+}
index ff060a2677d32a79a8436189886d6bf9581e3621..47be40d38e973cbc2e749f8283009a142a635047 100644 (file)
  */
 using System.ComponentModel;
 using System;
+using Tizen.NUI.BaseComponents;
 
 namespace Tizen.NUI
 {
+    /// <summary>
+    /// Enumeration for selecting how the mask source interprets pixel data
+    /// Alpha: Uses the alpha channel of the mask texture. (Default)
+    /// Luminance: Converts RGB to grayscale and uses the luminance as mask value.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public enum MaskEffectMode
+    {
+        Alpha = 0,
+        Luminance,
+    }
+
     /// <summary>
     /// View's optional render effect.
     /// Applications can apply RenderEffect as the example below :
@@ -66,5 +79,38 @@ namespace Tizen.NUI
         {
             return new BackgroundBlurEffect(Interop.BackgroundBlurEffect.New((uint)Math.Round(blurRadius, 0)));
         }
+
+        /// <summary>
+        /// Create a mask effect
+        /// </summary>
+        /// <remarks>
+        /// Created RenderEffect is immutable.
+        /// </remarks>
+        /// <param name="control">The mask source control.</param>
+        /// <returns>mask effect with given control.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static RenderEffect CreateMaskEffect(View control)
+        {
+            return new RenderEffect(Interop.MaskEffect.New(control.SwigCPtr));
+        }
+
+        /// <summary>
+        /// Create a mask effect
+        /// </summary>
+        /// <remarks>
+        /// Created RenderEffect is immutable.
+        /// </remarks>
+        /// <param name="control">The mask source control.</param>
+        /// <param name="maskMode">Defines pixel data type (alpha, luminance) used as the mask source.</param>
+        /// <param name="positionX">The X Position of mask source.</param>
+        /// <param name="positionY">The Y Position of mask source.</param>
+        /// <param name="scaleX">The X Scale of mask source.</param>
+        /// <param name="scaleY">The Y Scale of mask source.</param>
+        /// <returns>mask effect with given control.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static RenderEffect CreateMaskEffect(View control, MaskEffectMode maskMode, float positionX = 0.0f, float positionY = 0.0f, float scaleX = 1.0f, float scaleY = 1.0f)
+        {
+            return new RenderEffect(Interop.MaskEffect.New(control.SwigCPtr, maskMode, positionX, positionY, scaleX, scaleY));
+        }
     }
 }