Do not set VisualRenderer properties if we don't change it 78/319578/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 13 Feb 2025 05:46:47 +0000 (14:46 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 14 Feb 2025 09:19:23 +0000 (18:19 +0900)
Until now, we always set uniforms even if nothing changed.
To avoid this thing, let we check whether it is really changed,
and set transform uniforms only required.

Change-Id: I66def37b8635e3a8afca0d2f55ec9bff8cb525af
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
16 files changed:
dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/arc/arc-visual.cpp
dali-toolkit/internal/visuals/border/border-visual.cpp
dali-toolkit/internal/visuals/color/color-visual.cpp
dali-toolkit/internal/visuals/gradient/gradient-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/mesh/mesh-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/primitive/primitive-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.h
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp

index 905c9d9a33c786d1cbfc39737c43be014907e06d..93fbcbcdb44f73c5e5a96943e693350515513c39 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.
@@ -461,7 +461,7 @@ void AnimatedGradientVisual::StopAnimation()
 
 void AnimatedGradientVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index a738b9ae12e6a745ff11639969c2ad1021a3b02f..bcd3e9308be8c1db1e2cab2b0a539f5c7a710e79 100644 (file)
@@ -1031,7 +1031,7 @@ void AnimatedImageVisual::DoSetOffScene(Actor& actor)
 
 void AnimatedImageVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index a81c80f1e7a840455b6ee6356ca8ab966efc7bc9..354a63ec70ffd4ff88e7816ee8d32f3e38ab517a 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.
@@ -556,23 +556,31 @@ void AnimatedVectorImageVisual::DoSetOffScene(Actor& actor)
 
 void AnimatedVectorImageVisual::OnSetTransform()
 {
-  Vector2 visualSize = mImpl->mTransform.GetVisualSize(mImpl->mControlSize);
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
+  {
+    mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
+  }
 
-  if(IsOnScene() && visualSize != mVisualSize)
+  if(IsOnScene())
   {
-    DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSetTransform: width = %f, height = %f [%p]\n", visualSize.width, visualSize.height, this);
+    Vector2 visualSize = mImpl->mTransform.GetVisualSize(mImpl->mControlSize);
 
-    mVisualSize = visualSize;
+    if(visualSize != mVisualSize)
+    {
+      DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnSetTransform: width = %f, height = %f [%p]\n", visualSize.width, visualSize.height, this);
 
-    SetVectorImageSize();
+      mVisualSize = visualSize;
 
-    if(mPlayState == DevelImageVisual::PlayState::PLAYING && mAnimationData.playState != DevelImageVisual::PlayState::PLAYING)
-    {
-      mAnimationData.playState = DevelImageVisual::PlayState::PLAYING;
-      mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
-    }
+      SetVectorImageSize();
 
-    TriggerVectorRasterization();
+      if(mPlayState == DevelImageVisual::PlayState::PLAYING && mAnimationData.playState != DevelImageVisual::PlayState::PLAYING)
+      {
+        mAnimationData.playState = DevelImageVisual::PlayState::PLAYING;
+        mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_STATE;
+      }
+
+      TriggerVectorRasterization();
+    }
   }
 }
 
index b830276ccc9e9439c854a92e1e4b72ff05a9716f..e8c4e0264c2c052aac562bfc011d945801ab88d8 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.
@@ -186,6 +186,11 @@ void ArcVisual::OnSetTransform()
   if(mImpl->mRenderer)
   {
     mImpl->mRenderer.SetProperty(mRadiusIndex, mRadius);
+
+    if(mImpl->mTransformMapChanged)
+    {
+      mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
+    }
   }
 }
 
index ea6ea67ef0ab1227d0a021fc8b0d1c8da37680e5..943a91719fd9c043b10652e515e3da5658cee01d 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.
@@ -164,7 +164,7 @@ void BorderVisual::DoCreateInstancePropertyMap(Property::Map& map) const
 
 void BorderVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index f2d6f888c7327ae32f6db680bf59bd1032da0a63..3927dd38b3528e639b6620a95fa5bf2b7d469af0 100644 (file)
@@ -206,7 +206,7 @@ void ColorVisual::EnablePreMultipliedAlpha(bool preMultiplied)
 
 void ColorVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index 57c3c0848eb1db5c2e9579e6b66d838ab47d2f84..07be72ecf546cdae8467e35c7a3b6b7b6bb61614 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.
@@ -179,7 +179,7 @@ void GradientVisual::DoSetProperties(const Property::Map& propertyMap)
 
 void GradientVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index 256661882e745a7dbd8ad36c9aa8325fb0c05e66..4a3429077305e1ce717ee49dbc9ef17c87754211 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.
@@ -1066,7 +1066,7 @@ void ImageVisual::OnDoAction(const Dali::Property::Index actionId, const Dali::P
 
 void ImageVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index 7c8b0b8782c7f3f6ad5171266410979ea58e9a4a..f02f6e914e9cbbc658473148c377a7661e2d2d99 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.
@@ -235,7 +235,7 @@ void MeshVisual::DoSetProperty(Property::Index index, const Property::Value& val
 
 void MeshVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index b39056bca54068421ce482c945928789a17f3cdc..fec22bef143c056b94db8747612d9f0a515c4a60 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.
@@ -264,7 +264,7 @@ void NPatchVisual::DoSetOffScene(Actor& actor)
 
 void NPatchVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
@@ -432,8 +432,8 @@ Shader NPatchVisual::CreateShader()
 
   auto fragmentShader = mAuxiliaryResourceStatus == Toolkit::Visual::ResourceStatus::READY ? SHADER_NPATCH_VISUAL_MASK_SHADER_FRAG
                                                                                            : SHADER_NPATCH_VISUAL_SHADER_FRAG;
-  auto shaderType     = mAuxiliaryResourceStatus == Toolkit::Visual::ResourceStatus::READY ? VisualFactoryCache::NINE_PATCH_MASK_SHADER
-                                                                                           : VisualFactoryCache::NINE_PATCH_SHADER;
+  auto shaderType = mAuxiliaryResourceStatus == Toolkit::Visual::ResourceStatus::READY ? VisualFactoryCache::NINE_PATCH_MASK_SHADER
+                                                                                       : VisualFactoryCache::NINE_PATCH_SHADER;
 
   // ask loader for the regions
   if(mLoader.GetNPatchData(mId, data))
index 2465449d068b6d9e295aab346613b1be2bbf59d0..666846efe75fcbeda187289e9da6284209d822fb 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.
@@ -361,7 +361,7 @@ void PrimitiveVisual::DoCreateInstancePropertyMap(Property::Map& map) const
 
 void PrimitiveVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index e3019057105d514256261b572876c8138c81eebe..9f7610998dae1d67e379a9cca78aa39b042e0431 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.
@@ -489,7 +489,7 @@ void SvgVisual::RasterizeComplete(int32_t rasterizeId, Dali::TextureSet textureS
 
 void SvgVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
   }
index be5ce33b6ea588415cbd2bb4b0d2bb801bff8107..698f4cff4b426c47b4af34bf6543f3bbc0a446c3 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.
@@ -132,7 +132,8 @@ Internal::Visual::Base::Impl::Impl(FittingMode fittingMode, Toolkit::Visual::Typ
   mAlwaysUsingCornerSquareness(false),
   mIgnoreFittingMode(false),
   mPixelAreaSetByFittingMode(false),
-  mTransformMapSetForFittingMode(false)
+  mTransformMapSetForFittingMode(false),
+  mTransformMapChanged(false)
 {
 }
 
index 68f924bb2795f96721f9dfa7da43a8bef901bcca..12a445affe57f6faf0bff2dd5c058674a82a6df9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_BASE_DATA_IMPL_H
 
 /*
- * 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.
@@ -282,6 +282,7 @@ struct Base::Impl
   bool                            mIgnoreFittingMode : 1;             ///< Whether we need to ignore fitting mode.
   bool                            mPixelAreaSetByFittingMode : 1;     ///< Whether the pixel area is set for fitting mode.
   bool                            mTransformMapSetForFittingMode : 1; ///< Whether the transformMap is set for fitting mode.
+  bool                            mTransformMapChanged : 1;           ///< Whether the transformMap is changed or not. We'll be false after SetTransform called.
 };
 
 } // namespace Visual
index 375024eb6c8907092a1ef1c80c0b55966bdff1ca..5f69ef7eef3f3ec0b186b54b7ebfb26ea53ca418 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.
@@ -246,10 +246,14 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
           {
             // Unusual case. SetProperty called after OnInitialize().
             // Assume that DoAction call UPDATE_PROPERTY.
+            mImpl->mTransformMapChanged |= !map.Empty();
             mImpl->mTransform.UpdatePropertyMap(map);
 
             // Set Renderer uniforms, and change logics for subclasses.
             OnSetTransform();
+
+            // Reset flag here.
+            mImpl->mTransformMapChanged = false;
           }
           else
           {
@@ -526,6 +530,7 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap)
 void Visual::Base::SetTransformAndSize(const Property::Map& transform, Size controlSize)
 {
   mImpl->mControlSize = controlSize;
+  mImpl->mTransformMapChanged |= !transform.Empty();
   mImpl->mTransform.UpdatePropertyMap(transform);
 
 #if defined(DEBUG_ENABLED)
@@ -535,6 +540,9 @@ void Visual::Base::SetTransformAndSize(const Property::Map& transform, Size cont
 #endif
 
   OnSetTransform();
+
+  // Reset flag here.
+  mImpl->mTransformMapChanged = false;
 }
 
 void Visual::Base::SetName(const std::string& name)
index ae76d870cc9d238a48a02da81a130c539d308035..14444b61dd9dcd668d9c95efb07c8728fde52680 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.
@@ -194,7 +194,7 @@ Geometry WireframeVisual::CreateQuadWireframeGeometry()
 
 void WireframeVisual::OnSetTransform()
 {
-  if(mImpl->mRenderer)
+  if(mImpl->mRenderer && mImpl->mTransformMapChanged)
   {
     //Register transform properties
     mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);