-#ifndef __DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
-#define __DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
+#ifndef DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H
+#define DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
*
*/
+// EXTERNAL INCLUDES
+#include <cstdint>
+#include <memory> // for unique_ptr
+
// INTERNAL INCLUDES
+#include <dali/internal/common/memory-pool-object-allocator.h>
+#include <dali/internal/common/ordered-set.h>
+#include <dali/internal/event/size-negotiation/memory-pool-relayout-container.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
-#include <dali/internal/common/memory-pool-object-allocator.h>
-#include <dali/internal/event/size-negotiation/memory-pool-relayout-container.h>
-
namespace Dali
{
+namespace Integration
+{
+class RenderController;
+}
namespace Internal
{
-
/**
* @brief The relayout controller is responsible for taking request from actors to relayout their sizes.
* The requests are actioned on at the end of the frame where all actors that have made a request are
class RelayoutController : public Dali::BaseObject
{
public:
-
/**
* @brief Constructor.
* We should only create a unique instance.
+ * @param[in] controller to request a render from the RenderController if core is not processing events.
*/
- RelayoutController();
+ RelayoutController(Integration::RenderController& controller);
/**
* Destructor
*/
- virtual ~RelayoutController();
+ ~RelayoutController() override;
/**
* @brief Get the singleton of RelayoutController object.
* @param[in] actor The actor to request relayout on
* @param[in] dimension The dimension(s) to request the relayout on. Defaults to all dimensions
*/
- void RequestRelayout( Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
+ void RequestRelayout(Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
/**
* @brief Request to relayout of all actors in the sub-tree below the given actor.
*
* @param[in] actor The actor to request relayout on
*/
- void RequestRelayoutTree( Dali::Actor& actor );
+ void RequestRelayoutTree(Dali::Actor& actor);
/**
* @brief Force propagate relayout flags through the tree. This is similiar to Request Relayout
* @param[in] actor The actor to propagate from
* @param[in] dimension The dimension to propagate on
*/
- void PropagateFlags( Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS );
+ void PropagateFlags(Dali::Actor& actor, Dimension::Type dimension = Dimension::ALL_DIMENSIONS);
/**
* @brief Relayouts all actors that have been marked as dirty
*
* @param[in] enabled Flag to indicate whether the controller should be enabled or disabled
*/
- void SetEnabled( bool enabled );
+ void SetEnabled(bool enabled);
/**
* @brief Return true if the relayout controller is currently performing a relayout
*/
bool IsPerformingRelayout() const;
-public: // CALLBACKS
+ /**
+ * @brief Sets whether core is processing events.
+ *
+ * @param[in] processingEvents whether core is processing events.
+ */
+ void SetProcessingCoreEvents(bool processingEvents);
+
+ /**
+ * Get the capacity of the memory pool containing relayout info
+ * (It Should be regularly purged!)
+ */
+ uint32_t GetMemoryPoolCapacity();
+public: // CALLBACKS
/**
* @brief Callback raised after the application creates the scene
*/
*
* @param[in] object The object being destroyed
*/
- void OnObjectDestroyed( const Dali::RefObject* object );
+ void OnObjectDestroyed(const Dali::RefObject* object);
private:
-
- typedef Dali::Vector< BaseObject* > RawActorList;
+ using RawActorList = Dali::Internal::OrderedSet<Dali::Internal::Actor, false>;
/**
* @brief Request for relayout. Relays out whole scene.
*
* @param[in] actor The root of the sub tree to add
*/
- void AddRequest( Dali::Actor& actor );
+ void AddRequest(Dali::Actor& actor);
/**
* @brief Remove actor from request list
*
* @param[in] actor The root of the sub tree to remove
*/
- void RemoveRequest( Dali::Actor& actor );
+ void RemoveRequest(Dali::Actor& actor);
/**
* @brief Disconnect the Relayout() method from the Stage::EventProcessingFinishedSignal().
* @param[in] topOfSubTreeStack The top of the sub tree that this actor is in
* @param[in] potentialRedundantSubRoots Actors collected as potentially already being included in relayout
*/
- void PropagateAll( Dali::Actor& actor, Dimension::Type dimension, Dali::ActorContainer& topOfSubTreeStack, Dali::ActorContainer& potentialRedundantSubRoots );
+ void PropagateAll(Dali::Actor& actor, Dimension::Type dimension, std::vector<Dali::Actor>& topOfSubTreeStack, std::vector<Dali::Actor>& potentialRedundantSubRoots);
/**
* Queue an actor on the relayout container
* @param[in] actors The container to add the actor to
* @param[in] size The size that this actor should be
*/
- void QueueActor( Dali::Actor& actor, RelayoutContainer& actors, Vector2 size );
-
- /**
- * @brief Find the given object in the list and null it out
- *
- * @param[in] list The list to search
- * @param[in] object The object to search for
- */
- void FindAndZero( const RawActorList& list, const Dali::RefObject* object );
+ void QueueActor(Internal::Actor* actor, RelayoutContainer& actors, Vector2 size);
// Undefined
- RelayoutController(const RelayoutController&);
- RelayoutController& operator=(const RelayoutController&);
+ RelayoutController(const RelayoutController&) = delete;
+ RelayoutController& operator=(const RelayoutController&) = delete;
private:
+ Integration::RenderController& mRenderController;
+ MemoryPoolObjectAllocator<MemoryPoolRelayoutContainer::RelayoutInfo> mRelayoutInfoAllocator;
+
+ SlotDelegate<RelayoutController> mSlotDelegate;
- MemoryPoolObjectAllocator< MemoryPoolRelayoutContainer::RelayoutInfo > mRelayoutInfoAllocator;
+ RawActorList mDirtyLayoutSubTrees; ///< List of roots of sub trees that are dirty
- SlotDelegate< RelayoutController > mSlotDelegate;
+ std::unique_ptr<MemoryPoolRelayoutContainer> mRelayoutStack; ///< Stack for relayouting
- RawActorList mDirtyLayoutSubTrees; ///< List of roots of sub trees that are dirty
- MemoryPoolRelayoutContainer* mRelayoutStack; ///< Stack for relayouting
- 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.
- bool mPerformingRelayout : 1; ///< The relayout controller is currently performing a relayout
+ 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.
+ bool mPerformingRelayout : 1; ///< The relayout controller is currently performing a relayout
+ bool mProcessingCoreEvents : 1; ///< Whether core is processing events.
};
} // namespace Internal
} // namespace Dali
-#endif // __DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
+#endif // DALI_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H