From 6063631f23d1f82069076d544c369574bb01ced1 Mon Sep 17 00:00:00 2001 From: jmm Date: Tue, 25 Jun 2024 13:03:50 +0900 Subject: [PATCH] [NUI] Support View BackgroundBlurEffect --- .../src/internal/Interop/Interop.RenderEffect.cs | 17 ++++ src/Tizen.NUI/src/internal/Interop/Interop.View.cs | 6 ++ .../src/public/BaseComponents/ViewPublicMethods.cs | 22 +++++ src/Tizen.NUI/src/public/Utility/RenderEffect.cs | 96 ++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs create mode 100644 src/Tizen.NUI/src/public/Utility/RenderEffect.cs diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs b/src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs new file mode 100644 index 0000000..6165073 --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.RenderEffect.cs @@ -0,0 +1,17 @@ +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class BackgroundBlurEffect + { + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_BackgroundBlurEffect_New__SWIG_0")] + public static extern global::System.IntPtr New(); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_BackgroundBlurEffect_New__SWIG_1")] + public static extern global::System.IntPtr New(uint pixelRadius); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_BackgroundBlurEffect")] + public static extern void Delete(global::System.Runtime.InteropServices.HandleRef self); + } + } +} diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.View.cs b/src/Tizen.NUI/src/internal/Interop/Interop.View.cs index 42d6200..3783345 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.View.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.View.cs @@ -51,6 +51,12 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_ClearBackground")] public static extern void ClearBackground(global::System.Runtime.InteropServices.HandleRef jarg1); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_SetRenderEffect")] + public static extern void SetRenderEffect(global::System.Runtime.InteropServices.HandleRef self, global::System.Runtime.InteropServices.HandleRef effectRef); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_ClearRenderEffect")] + public static extern void ClearRenderEffect(global::System.Runtime.InteropServices.HandleRef self); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_View__SWIG_2")] public static extern global::System.IntPtr NewViewInternal(global::System.Runtime.InteropServices.HandleRef jarg1); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs index 5da4b3b..954bb1a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs @@ -312,6 +312,28 @@ namespace Tizen.NUI.BaseComponents } /// + /// Sets render effect to the view. The effect is applied to at most one view. + /// + /// A render effect to set. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetRenderEffect(RenderEffect effect) + { + Interop.View.SetRenderEffect(SwigCPtr, RenderEffect.getCPtr(effect)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Clears render effect. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void ClearRenderEffect() + { + Interop.View.ClearRenderEffect(SwigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + } + + /// /// Shows the view. /// /// diff --git a/src/Tizen.NUI/src/public/Utility/RenderEffect.cs b/src/Tizen.NUI/src/public/Utility/RenderEffect.cs new file mode 100644 index 0000000..9ff734f --- /dev/null +++ b/src/Tizen.NUI/src/public/Utility/RenderEffect.cs @@ -0,0 +1,96 @@ +/* + * Copyright(c) 2024 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.ComponentModel; +using System; + +namespace Tizen.NUI +{ + /// + /// View's optional render effect. + /// Applications can apply RenderEffect as the example below : + /// + /// + /// RenderEffect effect = RenderEffect.CreateBackgroundBlurEffect(20.0f); + /// + /// view.SetRenderEffect(effect); + /// view.ClearRenderEffect(); + /// + /// + /// Note that a view owns at most one render effect. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class RenderEffect : BaseHandle + { + internal RenderEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// + /// Create a background blur effect + /// + /// + /// Created RenderEffect is immutable. + /// + /// The blur radius value. The unit is pixel for standard cases. + /// Background blur effect with given blur radius. + [EditorBrowsable(EditorBrowsableState.Never)] + public static RenderEffect CreateBackgroundBlurEffect(float blurRadius) + { + return new BackgroundBlurEffect((uint)Math.Round(blurRadius, 0)); + } + } + + + /// + /// Applications can create BackgroundBlurEffect as : + /// + /// RenderEffect.CreateBackgroundBlurEffect(blurRadius); + /// + [EditorBrowsable(EditorBrowsableState.Never)] + sealed class BackgroundBlurEffect : RenderEffect + { + /// + /// Create a BackgroundBlurEffect. + /// The default values are: + /// uint blurRadius = 5; + /// + internal BackgroundBlurEffect() : this(Interop.BackgroundBlurEffect.New(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + /// + /// Create a BackgroundBlurEffect. + /// + /// Size of gaussian kernel, determines blur intensity. + internal BackgroundBlurEffect(uint blurRadius) : this(Interop.BackgroundBlurEffect.New(blurRadius), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + internal BackgroundBlurEffect(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + { + } + + /// This will not be public opened. + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.BackgroundBlurEffect.Delete(swigCPtr); + } + } +} -- 2.7.4