X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali%2Finternal%2Fevent%2Fsize-negotiation%2Frelayout-controller-impl.cpp;h=2d639f5fc28dc350fdb3dcab885ca9867549a975;hb=613f1ec636807462adb399d33585b0def8461ad4;hp=c32cebe1897c9e3d6bfaa7b866146f7d81693e80;hpb=aa03392fb87007c43c0fd38daf67d43ed93126c0;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp index c32cebe..2d639f5 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -16,7 +16,7 @@ */ // CLASS HEADER -#include "relayout-controller-impl.h" +#include // EXTERNAL INCLUDES #if defined(DEBUG_ENABLED) @@ -119,12 +119,11 @@ 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() -{ - delete mRelayoutStack; -} +RelayoutController::~RelayoutController() = default; RelayoutController* RelayoutController::Get() { @@ -155,8 +154,11 @@ void RelayoutController::RequestRelayout(Dali::Actor& actor, Dimension::Type dim return; } - std::vector potentialRedundantSubRoots; - std::vector topOfSubTreeStack; + std::vector& potentialRedundantSubRoots = mPotentialRedundantSubRoots; + std::vector& 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); @@ -197,6 +199,8 @@ void RelayoutController::RequestRelayout(Dali::Actor& actor, Dimension::Type dim RemoveRequest(subRoot); } + potentialRedundantSubRoots.clear(); + if(!mProcessingCoreEvents) { mRenderController.RequestProcessEventsOnIdle(false); @@ -372,9 +376,9 @@ void RelayoutController::AddRequest(Dali::Actor& actor) Internal::Actor* actorPtr = &GetImplementation(actor); // Only add the rootActor if it is not already recorded - auto itr = std::find(mDirtyLayoutSubTrees.begin(), mDirtyLayoutSubTrees.end(), actorPtr); + auto iter = mDirtyLayoutSubTrees.Find(actorPtr); - if(itr == mDirtyLayoutSubTrees.end()) + if(iter == mDirtyLayoutSubTrees.End()) { mDirtyLayoutSubTrees.PushBack(actorPtr); } @@ -383,11 +387,7 @@ void RelayoutController::AddRequest(Dali::Actor& actor) void RelayoutController::RemoveRequest(Dali::Actor& actor) { Internal::Actor* actorPtr = &GetImplementation(actor); - - mDirtyLayoutSubTrees.Erase(std::remove(mDirtyLayoutSubTrees.begin(), - mDirtyLayoutSubTrees.end(), - actorPtr), - mDirtyLayoutSubTrees.end()); + mDirtyLayoutSubTrees.EraseObject(actorPtr); } void RelayoutController::Request() @@ -404,8 +404,7 @@ void RelayoutController::Request() void RelayoutController::OnObjectDestroyed(const Dali::RefObject* object) { - // Search for and null the object if found in the following lists - FindAndZero(mDirtyLayoutSubTrees, object); + mDirtyLayoutSubTrees.EraseObject(static_cast(object)); } void RelayoutController::Relayout() @@ -446,7 +445,8 @@ void RelayoutController::Relayout() { Dali::Actor actor; Vector2 size; - mRelayoutStack->Get(mRelayoutStack->Size() - 1, actor, size); + + mRelayoutStack->GetBack(actor, size); Actor& actorImpl = GetImplementation(actor); mRelayoutStack->PopBack(); @@ -487,18 +487,6 @@ void RelayoutController::SetProcessingCoreEvents(bool processingEvents) mProcessingCoreEvents = processingEvents; } -void RelayoutController::FindAndZero(const RawActorList& list, const Dali::RefObject* object) -{ - // Object has been destroyed so clear it from this list - for(auto& actor : list) - { - if(actor && (actor == object)) - { - actor = nullptr; // Reset the pointer in the list. We don't want to remove it in case something is iterating over the list. - } - } -} - uint32_t RelayoutController::GetMemoryPoolCapacity() { return mRelayoutInfoAllocator.GetCapacity();