Add background blur effect option: blur once 80/321580/1
authorjmm <j0064423.lee@samsung.com>
Tue, 25 Mar 2025 09:01:51 +0000 (18:01 +0900)
committerjmm <j0064423.lee@samsung.com>
Tue, 25 Mar 2025 09:01:51 +0000 (18:01 +0900)
Change-Id: I52b772f351af93a8a3797b35be9a81e9052da86f

automated-tests/src/dali-toolkit/utc-Dali-RenderEffect.cpp
dali-toolkit/internal/controls/render-effects/blur-effect-impl.cpp
dali-toolkit/internal/controls/render-effects/blur-effect-impl.h
dali-toolkit/public-api/controls/render-effects/render-effect.cpp
dali-toolkit/public-api/controls/render-effects/render-effect.h

index 20cae511811349856365ef00947d3822264d70d3..67d0187b6fd35a605887e6897fa9974950c407a0 100644 (file)
@@ -818,3 +818,31 @@ int UtcDaliRenderEffectReInitialize(void)
 
   END_TEST;
 }
+
+int UtcDaliRenderEffectBlurOnce(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliRenderEffectBlurOnce with background blur effect");
+
+  Integration::Scene scene = application.GetScene();
+
+  Control control = Control::New();
+  control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+  control.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f));
+
+  scene.Add(control);
+
+  // Add render effect during scene on.
+  control.SetRenderEffect(RenderEffect::CreateBackgroundBlurEffect(0.5f, 20u, true));
+
+  application.SendNotification();
+
+  RenderTaskList taskList = scene.GetRenderTaskList();
+
+  // Render effect activated.
+  DALI_TEST_EQUALS(4u, taskList.GetTaskCount(), TEST_LOCATION);
+  tet_printf("order : %d\n", taskList.GetTask(taskList.GetTaskCount() - 1).GetOrderIndex());
+  DALI_TEST_EQUALS(INT32_MIN + 2, taskList.GetTask(taskList.GetTaskCount() - 1).GetOrderIndex(), TEST_LOCATION);
+
+  END_TEST;
+}
index c7962b3b9fd2045b877ba890897b60e6f53d4400..bae12308ff504e4a98f46faf7088034392f5d0ad 100644 (file)
@@ -78,11 +78,12 @@ BlurEffectImpl::BlurEffectImpl(bool isBackground)
   mDownscaledPixelRadius(static_cast<uint32_t>(BLUR_EFFECT_PIXEL_RADIUS * BLUR_EFFECT_DOWNSCALE_FACTOR)),
   mBellCurveWidth(Math::MACHINE_EPSILON_1),
   mSkipBlur(false),
+  mBlurOnce(false),
   mIsBackground(isBackground)
 {
 }
 
-BlurEffectImpl::BlurEffectImpl(float downscaleFactor, uint32_t blurRadius, bool isBackground)
+BlurEffectImpl::BlurEffectImpl(float downscaleFactor, uint32_t blurRadius, bool blurOnce, bool isBackground)
 : RenderEffectImpl(),
   mInternalRoot(Actor::New()),
   mDownscaleFactor(downscaleFactor),
@@ -90,6 +91,7 @@ BlurEffectImpl::BlurEffectImpl(float downscaleFactor, uint32_t blurRadius, bool
   mDownscaledPixelRadius(BLUR_EFFECT_PIXEL_RADIUS),
   mBellCurveWidth(Math::MACHINE_EPSILON_1),
   mSkipBlur(false),
+  mBlurOnce(blurOnce),
   mIsBackground(isBackground)
 {
   if(DALI_UNLIKELY(mDownscaleFactor < MINIMUM_DOWNSCALE_FACTOR || mDownscaleFactor > MAXIMUM_DOWNSCALE_FACTOR))
@@ -135,16 +137,16 @@ BlurEffectImplPtr BlurEffectImpl::New(bool isBackground)
   return handle;
 }
 
-BlurEffectImplPtr BlurEffectImpl::New(float downscaleFactor, uint32_t blurRadius, bool isBackground)
+BlurEffectImplPtr BlurEffectImpl::New(float downscaleFactor, uint32_t blurRadius, bool blurOnce, bool isBackground)
 {
-  BlurEffectImplPtr handle = new BlurEffectImpl(downscaleFactor, blurRadius, isBackground);
+  BlurEffectImplPtr handle = new BlurEffectImpl(downscaleFactor, blurRadius, blurOnce, isBackground);
   handle->Initialize();
   return handle;
 }
 
 RenderEffectImplPtr BlurEffectImpl::Clone() const
 {
-  BlurEffectImplPtr blurEffectImpl = new BlurEffectImpl(mDownscaleFactor, mPixelRadius, mIsBackground);
+  BlurEffectImplPtr blurEffectImpl = new BlurEffectImpl(mDownscaleFactor, mPixelRadius, mBlurOnce, mIsBackground);
   blurEffectImpl->Initialize();
   return RenderEffectImplPtr(blurEffectImpl);
 }
@@ -413,6 +415,20 @@ void BlurEffectImpl::CreateRenderTasks(Integration::SceneHolder sceneHolder, con
   // Clear sourceTexture as Transparent.
   mVerticalBlurTask.SetClearEnabled(true);
   mVerticalBlurTask.SetClearColor(Color::TRANSPARENT);
+
+  // Adjust refresh rate
+  if(mBlurOnce)
+  {
+    mSourceRenderTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
+    mHorizontalBlurTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
+    mVerticalBlurTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
+  }
+  else
+  {
+    mSourceRenderTask.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
+    mHorizontalBlurTask.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
+    mVerticalBlurTask.SetRefreshRate(RenderTask::REFRESH_ALWAYS);
+  }
 }
 
 void BlurEffectImpl::DestroyRenderTasks()
index 5c895672a5e3f9634c79cf1be0a053f60a1ce923..952f896bd88462f118098903f395abdda6d37ae4 100644 (file)
@@ -63,10 +63,11 @@ public:
    *
    * @param[in] downscaleFactor This value should reside in the range [0.0, 1.0].
    * @param[in] blurRadius The radius of Gaussian kernel.
+   * @param[in] blurOnce Whether to blur once or always. Default is false(always).
    * @param[in] isBackground True when blurring background, False otherwise
    * @return A handle to a newly allocated Dali resource
    */
-  static BlurEffectImplPtr New(float downscaleFactor, uint32_t blurRadius, bool isBackground);
+  static BlurEffectImplPtr New(float downscaleFactor, uint32_t blurRadius, bool blurOnce, bool isBackground);
 
   /**
    * @copydoc Toolkit::Intenral::RenderEffectImpl::Clone
@@ -94,9 +95,10 @@ protected:
    * @brief Creates an uninitialized blur effect implementation
    * @param[in] downscaleFactor This value should reside in the range [0.0, 1.0].
    * @param[in] blurRadius The radius of Gaussian kernel.
+   * @param[in] blurOnce Whether to blur once or always. Default is false(always).
    * @param[in] isBackground True when blurring background, False otherwise
    */
-  BlurEffectImpl(float downscaleFactor, uint32_t blurRadius, bool isBackground);
+  BlurEffectImpl(float downscaleFactor, uint32_t blurRadius, bool blurOnce, bool isBackground);
 
   /**
    * @brief Destructor
@@ -206,6 +208,7 @@ private:
   float    mBellCurveWidth;
 
   bool mSkipBlur : 1;
+  bool mBlurOnce : 1;
   bool mIsBackground : 1;
 };
 } // namespace Internal
index fddf530006ea6b01864e09763d4a0aa012156dc0..3dd0330f9272e520f847ff220670c2c421f1614b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -42,9 +42,9 @@ RenderEffect RenderEffect::CreateBackgroundBlurEffect()
   return RenderEffect(internal.Get());
 }
 
-RenderEffect RenderEffect::CreateBackgroundBlurEffect(float downscaleFactor, uint32_t blurRadius)
+RenderEffect RenderEffect::CreateBackgroundBlurEffect(float downscaleFactor, uint32_t blurRadius, bool blurOnce)
 {
-  Internal::BlurEffectImplPtr internal = Internal::BlurEffectImpl::New(downscaleFactor, blurRadius, true);
+  Internal::BlurEffectImplPtr internal = Internal::BlurEffectImpl::New(downscaleFactor, blurRadius, blurOnce, true);
   return RenderEffect(internal.Get());
 }
 } // namespace Toolkit
index 8cf3cbc23028caa8b1b60de42d626e102524dd71..57a11ccc8b302dd85d43fcf5018d3a172c1d67f3 100644 (file)
@@ -80,9 +80,10 @@ public:
    * @brief Creates background blur effect.
    * @param[in] downscaleFactor Input texture downscaler for better performance.
    * @param[in] blurRadius Gaussian kernel size.
+   * @param[in] blurOnce Whether to perform blur once or always. Default is false(always).
    * @SINCE_2_4.1
    */
-  static RenderEffect CreateBackgroundBlurEffect(float downscaleFactor, uint32_t blurRadius);
+  static RenderEffect CreateBackgroundBlurEffect(float downscaleFactor, uint32_t blurRadius, bool blurOnce = false);
 
 public: // Not intended for Application developers
   ///@cond internal