From 69adfeca65eac20b1864d40e2f21e5e79ad375a6 Mon Sep 17 00:00:00 2001 From: Chihun Jeong <50663828+ANZ1217@users.noreply.github.com> Date: Tue, 13 May 2025 13:07:39 +0900 Subject: [PATCH] [NUI] Introduce MaskEffect (#6905) Co-authored-by: ANZ1217 --- .../internal/Interop/Interop.MaskEffect.cs | 13 ++++++ .../src/public/RenderEffects/RenderEffect.cs | 46 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/Tizen.NUI/src/internal/Interop/Interop.MaskEffect.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 index 000000000..fdb030bce --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.MaskEffect.cs @@ -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); + } + } +} diff --git a/src/Tizen.NUI/src/public/RenderEffects/RenderEffect.cs b/src/Tizen.NUI/src/public/RenderEffects/RenderEffect.cs index ff060a267..47be40d38 100644 --- a/src/Tizen.NUI/src/public/RenderEffects/RenderEffect.cs +++ b/src/Tizen.NUI/src/public/RenderEffects/RenderEffect.cs @@ -16,9 +16,22 @@ */ using System.ComponentModel; using System; +using Tizen.NUI.BaseComponents; namespace Tizen.NUI { + /// + /// 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. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum MaskEffectMode + { + Alpha = 0, + Luminance, + } + /// /// 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))); } + + /// + /// Create a mask effect + /// + /// + /// Created RenderEffect is immutable. + /// + /// The mask source control. + /// mask effect with given control. + [EditorBrowsable(EditorBrowsableState.Never)] + public static RenderEffect CreateMaskEffect(View control) + { + return new RenderEffect(Interop.MaskEffect.New(control.SwigCPtr)); + } + + /// + /// Create a mask effect + /// + /// + /// Created RenderEffect is immutable. + /// + /// The mask source control. + /// Defines pixel data type (alpha, luminance) used as the mask source. + /// The X Position of mask source. + /// The Y Position of mask source. + /// The X Scale of mask source. + /// The Y Scale of mask source. + /// mask effect with given control. + [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)); + } } } -- 2.34.1