/*
- * 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.
/**
* @brief Keep a static recursionstack vector to avoid creating temporary vectors every Relayout().
*/
-static Dali::Internal::ActorSizer::ActorDimensionStack gRecursionStack{};
-
+Dali::Internal::ActorSizer::ActorDimensionStack& GetRecursionStack()
+{
+ static Dali::Internal::ActorSizer::ActorDimensionStack gRecursionStack{};
+ return gRecursionStack;
+}
} // namespace
namespace Dali::Internal
if(mTargetSize != size || mTargetSizeDirtyFlag)
{
mTargetSizeDirtyFlag = false;
- mTargetSize = size;
+ mTargetSize = size;
// Update the preferred size after relayoutting
// It should be used in the next relayoutting
void ActorSizer::NegotiateDimensions(const Vector2& allocatedSize)
{
// Negotiate all dimensions that require it
- gRecursionStack.clear();
+ GetRecursionStack().clear();
for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
{
const Dimension::Type dimension = static_cast<Dimension::Type>(1 << i);
// Negotiate
- NegotiateDimension(dimension, allocatedSize, gRecursionStack);
+ NegotiateDimension(dimension, allocatedSize, GetRecursionStack());
}
}
namespace
{
//Memory pool used to allocate new RenderItems. Memory used by this pool will be released when shutting down DALi
-Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderItem> gRenderItemPool;
+Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderItem>& GetRenderItemPool()
+{
+ static Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderItem> gRenderItemPool;
+ return gRenderItemPool;
+}
} // namespace
namespace Dali
{
RenderItem* RenderItem::New()
{
- return new(gRenderItemPool.AllocateRaw()) RenderItem();
+ return new(GetRenderItemPool().AllocateRaw()) RenderItem();
}
RenderItemKey RenderItem::NewKey()
{
- void* ptr = gRenderItemPool.AllocateRaw();
- auto key = gRenderItemPool.GetKeyFromPtr(static_cast<RenderItem*>(ptr));
+ void* ptr = GetRenderItemPool().AllocateRaw();
+ auto key = GetRenderItemPool().GetKeyFromPtr(static_cast<RenderItem*>(ptr));
new(ptr) RenderItem();
return RenderItemKey(key);
}
RenderItem* RenderItem::Get(RenderItemKey::KeyType key)
{
- return gRenderItemPool.GetPtrFromKey(key);
+ return GetRenderItemPool().GetPtrFromKey(key);
}
RenderItemKey RenderItem::GetKey(const RenderItem& renderItem)
{
- return RenderItemKey(gRenderItemPool.GetKeyFromPtr(const_cast<RenderItem*>(&renderItem)));
+ return RenderItemKey(GetRenderItemPool().GetKeyFromPtr(const_cast<RenderItem*>(&renderItem)));
}
RenderItemKey RenderItem::GetKey(RenderItem* renderItem)
{
- return RenderItemKey(gRenderItemPool.GetKeyFromPtr(renderItem));
+ return RenderItemKey(GetRenderItemPool().GetKeyFromPtr(renderItem));
}
ClippingBox RenderItem::CalculateTransformSpaceAABB(const Matrix& transformMatrix, const Vector3& position, const Vector3& size)
void RenderItem::operator delete(void* ptr)
{
- gRenderItemPool.Free(static_cast<RenderItem*>(ptr));
+ GetRenderItemPool().Free(static_cast<RenderItem*>(ptr));
}
uint32_t RenderItem::GetMemoryPoolCapacity()
{
- return gRenderItemPool.GetCapacity();
+ return GetRenderItemPool().GetCapacity();
}
} // namespace SceneGraph
/*
- * 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.
namespace //Unnamed namespace
{
//Memory pool used to allocate new animations. Memory used by this pool will be released when shutting down DALi
-Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Animation> gAnimationMemoryPool;
+Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Animation>& GetAnimationMemoryPool()
+{
+ static Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Animation> gAnimationMemoryPool;
+ return gAnimationMemoryPool;
+}
inline void WrapInPlayRange(float& elapsed, const float& playRangeStartSeconds, const float& playRangeEndSeconds)
{
{
Animation* Animation::New(float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, EndAction endAction, EndAction disconnectAction)
{
- return new(gAnimationMemoryPool.AllocateRawThreadSafe()) Animation(durationSeconds, speedFactor, playRange, loopCount, endAction, disconnectAction);
+ return new(GetAnimationMemoryPool().AllocateRawThreadSafe()) Animation(durationSeconds, speedFactor, playRange, loopCount, endAction, disconnectAction);
}
Animation::Animation(float durationSeconds, float speedFactor, const Vector2& playRange, int32_t loopCount, Dali::Animation::EndAction endAction, Dali::Animation::EndAction disconnectAction)
void Animation::operator delete(void* ptr)
{
- gAnimationMemoryPool.FreeThreadSafe(static_cast<Animation*>(ptr));
+ GetAnimationMemoryPool().FreeThreadSafe(static_cast<Animation*>(ptr));
}
void Animation::SetDuration(float durationSeconds)
uint32_t Animation::GetMemoryPoolCapacity()
{
- return gAnimationMemoryPool.GetCapacity();
+ return GetAnimationMemoryPool().GetCapacity();
}
} // namespace SceneGraph
/*
- * 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.
{
// Memory pool used to allocate new nodes. Memory used by this pool will be released when process dies
// or DALI library is unloaded
-Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node> gNodeMemoryPool;
+Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node>& GetNodeMemoryPool()
+{
+ static Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node> gNodeMemoryPool;
+ return gNodeMemoryPool;
+}
#ifdef DEBUG_ENABLED
// keep track of nodes alive, to ensure we have 0 when the process exits or DALi library is unloaded
int32_t gNodeCount = 0;
Node* Node::New()
{
- return new(gNodeMemoryPool.AllocateRawThreadSafe()) Node;
+ return new(GetNodeMemoryPool().AllocateRawThreadSafe()) Node;
}
void Node::Delete(Node* node)
node->~Node();
// Mark the memory it used as free in the memory pool
- gNodeMemoryPool.FreeThreadSafe(node);
+ GetNodeMemoryPool().FreeThreadSafe(node);
}
else
{
uint32_t Node::GetMemoryPoolCapacity()
{
- return gNodeMemoryPool.GetCapacity();
+ return GetNodeMemoryPool().GetCapacity();
}
} // namespace SceneGraph
/*
- * 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.
namespace
{
//Memory pool used to allocate new camera. Memory used by this pool will be released when shutting down DALi
-MemoryPoolObjectAllocator<Camera> gCameraMemoryPool;
+MemoryPoolObjectAllocator<Camera>& GetCameraMemoryPool()
+{
+ static MemoryPoolObjectAllocator<Camera> gCameraMemoryPool;
+ return gCameraMemoryPool;
+}
template<typename T>
T Sign(T value)
Camera* Camera::New()
{
- return new(gCameraMemoryPool.AllocateRawThreadSafe()) Camera();
+ return new(GetCameraMemoryPool().AllocateRawThreadSafe()) Camera();
}
Camera::~Camera() = default;
void Camera::operator delete(void* ptr)
{
- gCameraMemoryPool.FreeThreadSafe(static_cast<Camera*>(ptr));
+ GetCameraMemoryPool().FreeThreadSafe(static_cast<Camera*>(ptr));
}
void Camera::SetType(Dali::Camera::Type type)
/*
- * 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.
namespace //Unnamed namespace
{
//Memory pool used to allocate new RenderTaskLists. Memory used by this pool will be released when shutting down DALi
-Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderTaskList> gRenderTaskListMemoryPool;
-
+Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderTaskList>& GetRenderTaskListMemoryPool()
+{
+ static Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::RenderTaskList> gRenderTaskListMemoryPool;
+ return gRenderTaskListMemoryPool;
+}
} // unnamed namespace
namespace Dali
{
RenderTaskList* RenderTaskList::New()
{
- return new(gRenderTaskListMemoryPool.AllocateRawThreadSafe()) RenderTaskList();
+ return new(GetRenderTaskListMemoryPool().AllocateRawThreadSafe()) RenderTaskList();
}
RenderTaskList::RenderTaskList()
void RenderTaskList::operator delete(void* ptr)
{
- gRenderTaskListMemoryPool.FreeThreadSafe(static_cast<RenderTaskList*>(ptr));
+ GetRenderTaskListMemoryPool().FreeThreadSafe(static_cast<RenderTaskList*>(ptr));
}
void RenderTaskList::SetRenderMessageDispatcher(RenderMessageDispatcher* renderMessageDispatcher)
uint32_t RenderTaskList::GetMemoryPoolCapacity()
{
- return gRenderTaskListMemoryPool.GetCapacity();
+ return GetRenderTaskListMemoryPool().GetCapacity();
}
} // namespace SceneGraph
#endif
// Memory pool used to allocate new renderers. Memory used by this pool will be released when shutting down DALi
-MemoryPoolObjectAllocator<Renderer> gRendererMemoryPool;
+MemoryPoolObjectAllocator<Renderer>& GetRendererMemoryPool()
+{
+ static MemoryPoolObjectAllocator<Renderer> gRendererMemoryPool;
+ return gRendererMemoryPool;
+}
// Flags for re-sending data to renderer.
enum Flags
RendererKey Renderer::NewKey()
{
- void* ptr = gRendererMemoryPool.AllocateRawThreadSafe();
- auto key = gRendererMemoryPool.GetKeyFromPtr(static_cast<Renderer*>(ptr));
+ void* ptr = GetRendererMemoryPool().AllocateRawThreadSafe();
+ auto key = GetRendererMemoryPool().GetKeyFromPtr(static_cast<Renderer*>(ptr));
new(ptr) Renderer();
return RendererKey(key);
}
void Renderer::operator delete(void* ptr)
{
- gRendererMemoryPool.FreeThreadSafe(static_cast<Renderer*>(ptr));
+ GetRendererMemoryPool().FreeThreadSafe(static_cast<Renderer*>(ptr));
}
Renderer* Renderer::Get(RendererKey::KeyType rendererKey)
{
- return gRendererMemoryPool.GetPtrFromKey(rendererKey);
+ return GetRendererMemoryPool().GetPtrFromKey(rendererKey);
}
RendererKey Renderer::GetKey(const Renderer& renderer)
{
- return RendererKey(gRendererMemoryPool.GetKeyFromPtr(const_cast<Renderer*>(&renderer)));
+ return RendererKey(GetRendererMemoryPool().GetKeyFromPtr(const_cast<Renderer*>(&renderer)));
}
RendererKey Renderer::GetKey(Renderer* renderer)
{
- return RendererKey(gRendererMemoryPool.GetKeyFromPtr(renderer));
+ return RendererKey(GetRendererMemoryPool().GetKeyFromPtr(renderer));
}
bool Renderer::PrepareRender(BufferIndex updateBufferIndex)
uint32_t Renderer::GetMemoryPoolCapacity()
{
- return gRendererMemoryPool.GetCapacity();
+ return GetRendererMemoryPool().GetCapacity();
}
void Renderer::OnMappingChanged()
namespace //Unnamed namespace
{
//Memory pool used to allocate new texture sets. Memory used by this pool will be released when shutting down DALi
-Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::TextureSet> gTextureSetMemoryPool;
+Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::TextureSet>& GetTextureSetMemoryPool()
+{
+ static Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::TextureSet> gTextureSetMemoryPool;
+ return gTextureSetMemoryPool;
+}
} // namespace
namespace Dali
{
TextureSet* TextureSet::New()
{
- return new(gTextureSetMemoryPool.AllocateRawThreadSafe()) TextureSet();
+ return new(GetTextureSetMemoryPool().AllocateRawThreadSafe()) TextureSet();
}
TextureSet::TextureSet()
void TextureSet::operator delete(void* ptr)
{
- gTextureSetMemoryPool.FreeThreadSafe(static_cast<TextureSet*>(ptr));
+ GetTextureSetMemoryPool().FreeThreadSafe(static_cast<TextureSet*>(ptr));
}
void TextureSet::SetSampler(uint32_t index, Render::Sampler* sampler)
uint32_t TextureSet::GetMemoryPoolCapacity()
{
- return gTextureSetMemoryPool.GetCapacity();
+ return GetTextureSetMemoryPool().GetCapacity();
}
} // namespace SceneGraph