Make relayout temperal vector as member. 50/289750/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 14 Mar 2023 06:37:38 +0000 (15:37 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 14 Mar 2023 13:58:49 +0000 (22:58 +0900)
To avoid multiple times of size reversing,
Let we just keep static vector in relayout controller member value.

RequestRelayout API called very frequency. So it can reduce update time minor

Change-Id: Ifea9029831eb7e9fb63ea94fbe051cc39ffcbc00
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/event/size-negotiation/relayout-controller-impl.cpp
dali/internal/event/size-negotiation/relayout-controller-impl.h

index 93585f6..2d639f5 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 // CLASS HEADER
-#include "relayout-controller-impl.h"
+#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
 
 // EXTERNAL INCLUDES
 #if defined(DEBUG_ENABLED)
@@ -119,6 +119,8 @@ RelayoutController::RelayoutController(Integration::RenderController& controller
 {
   // Make space for 32 controls to avoid having to copy construct a lot in the beginning
   mRelayoutStack->Reserve(32);
+  mPotentialRedundantSubRoots.reserve(32);
+  mTopOfSubTreeStack.reserve(32);
 }
 
 RelayoutController::~RelayoutController() = default;
@@ -152,8 +154,11 @@ void RelayoutController::RequestRelayout(Dali::Actor& actor, Dimension::Type dim
     return;
   }
 
-  std::vector<Dali::Actor> potentialRedundantSubRoots;
-  std::vector<Dali::Actor> topOfSubTreeStack;
+  std::vector<Dali::Actor>& potentialRedundantSubRoots = mPotentialRedundantSubRoots;
+  std::vector<Dali::Actor>& topOfSubTreeStack          = mTopOfSubTreeStack;
+
+  DALI_ASSERT_ALWAYS(potentialRedundantSubRoots.empty() && "potentialRedundantSubRoots must be empty before RequestRelayout!");
+  DALI_ASSERT_ALWAYS(topOfSubTreeStack.empty() && "topOfSubTreeStack must be empty before RequestRelayout!");
 
   topOfSubTreeStack.push_back(actor);
 
@@ -194,6 +199,8 @@ void RelayoutController::RequestRelayout(Dali::Actor& actor, Dimension::Type dim
     RemoveRequest(subRoot);
   }
 
+  potentialRedundantSubRoots.clear();
+
   if(!mProcessingCoreEvents)
   {
     mRenderController.RequestProcessEventsOnIdle(false);
index e524406..91ffd97 100644 (file)
@@ -206,6 +206,9 @@ private:
 
   std::unique_ptr<MemoryPoolRelayoutContainer> mRelayoutStack; ///< Stack for relayouting
 
+  std::vector<Dali::Actor> mPotentialRedundantSubRoots; ///< Stack of Actor when RequestLayout comes. Keep it as member to avoid vector size reserving.
+  std::vector<Dali::Actor> mTopOfSubTreeStack;
+
   bool mRelayoutConnection : 1;   ///< Whether EventProcessingFinishedSignal signal is connected.
   bool mRelayoutFlag : 1;         ///< Relayout flag to avoid unnecessary calls
   bool mEnabled : 1;              ///< Initially disabled. Must be enabled at some point.