[Tizen] Change DebugPriority name and Debug priority
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / object-profiler.cpp
index 6651190..749c361 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 20207 Samsung Electronics Co., Ltd.
+ * Copyright (c) 20227 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.
 #include <dali/internal/system/common/object-profiler.h>
 
 // EXTERNAL INCLUDES
-#include <stdlib.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/profiling.h>
-#include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/type-registry.h>
+#include <stdlib.h>
 
 using std::string;
 using namespace Dali::Integration::Profiling;
@@ -35,19 +35,18 @@ namespace Internal
 {
 namespace Adaptor
 {
-
-ObjectProfiler::ObjectProfiler( Dali::ObjectRegistry objectRegistry, uint32_t timeInterval )
-: mObjectRegistry( objectRegistry )
+ObjectProfiler::ObjectProfiler(Dali::ObjectRegistry objectRegistry, uint32_t timeInterval)
+: mObjectRegistry(objectRegistry)
 {
   // This class must be created after the Stage; this means it doesn't count the initial objects
   // that are created by the stage (base layer, default camera actor)
 
-  mTimer = Dali::Timer::New( timeInterval * 1000 );
-  mTimer.TickSignal().Connect( this, &ObjectProfiler::OnTimeout );
+  mTimer = Dali::Timer::New(timeInterval * 1000);
+  mTimer.TickSignal().Connect(this, &ObjectProfiler::OnTimeout);
   mTimer.Start();
 
-  mObjectRegistry.ObjectCreatedSignal().Connect( this, &ObjectProfiler::OnObjectCreated );
-  mObjectRegistry.ObjectDestroyedSignal().Connect( this, &ObjectProfiler::OnObjectDestroyed );
+  mObjectRegistry.ObjectCreatedSignal().Connect(this, &ObjectProfiler::OnObjectCreated);
+  mObjectRegistry.ObjectDestroyedSignal().Connect(this, &ObjectProfiler::OnObjectDestroyed);
 }
 
 ObjectProfiler::~ObjectProfiler()
@@ -56,21 +55,19 @@ ObjectProfiler::~ObjectProfiler()
 
 void ObjectProfiler::DisplayInstanceCounts()
 {
-  for( auto&& element : mInstanceCountContainer )
+  for(auto&& element : mInstanceCountContainer)
   {
-    std::size_t memorySize = GetMemorySize( element.first, element.second );
-    if( memorySize > 0 )
+    std::size_t memorySize = GetMemorySize(element.first, element.second);
+    if(memorySize > 0)
     {
-      LogMessage( Debug::DebugInfo, "%-30s: % 4d  Memory MemorySize: ~% 6.1f kB\n",
-                  element.first.c_str(), element.second, memorySize / 1024.0f );
+      LogMessage(Debug::INFO, "%-30s: % 4d  Memory MemorySize: ~% 6.1f kB\n", element.first.c_str(), element.second, memorySize / 1024.0f);
     }
     else
     {
-      LogMessage( Debug::DebugInfo, "%-30s: % 4d\n",
-                  element.first.c_str(), element.second );
+      LogMessage(Debug::INFO, "%-30s: % 4d\n", element.first.c_str(), element.second);
     }
   }
-  LogMessage(Debug::DebugInfo, "\n");
+  LogMessage(Debug::INFO, "\n");
 }
 
 bool ObjectProfiler::OnTimeout()
@@ -82,7 +79,7 @@ bool ObjectProfiler::OnTimeout()
 void ObjectProfiler::OnObjectCreated(BaseHandle handle)
 {
   string theType = handle.GetTypeName();
-  if( theType.empty() )
+  if(theType.empty())
   {
     DALI_LOG_ERROR("Object created from an unregistered type\n");
     theType = "<Unregistered>";
@@ -91,18 +88,18 @@ void ObjectProfiler::OnObjectCreated(BaseHandle handle)
   mInstanceTypes.push_back(InstanceTypePair(&handle.GetBaseObject(), theType));
 
   bool found = false;
-  for( auto&& element : mInstanceCountContainer )
+  for(auto&& element : mInstanceCountContainer)
   {
-    if( element.first == theType )
+    if(element.first == theType)
     {
       element.second++;
       found = true;
     }
   }
-  if( !found )
+  if(!found)
   {
-    InstanceCountPair instanceCount( theType, 1 );
-    mInstanceCountContainer.emplace_back( instanceCount );
+    InstanceCountPair instanceCount(theType, 1);
+    mInstanceCountContainer.emplace_back(instanceCount);
   }
 }
 
@@ -111,29 +108,28 @@ void ObjectProfiler::OnObjectDestroyed(const Dali::RefObject* object)
   const BaseObject* baseObject = static_cast<const BaseObject*>(object);
 
   const auto end = mInstanceTypes.end();
-  for( auto iter = mInstanceTypes.begin(); iter != end; ++iter )
+  for(auto iter = mInstanceTypes.begin(); iter != end; ++iter)
   {
-    if( iter->first == baseObject )
+    if(iter->first == baseObject)
     {
       const auto& theType = iter->second;
-      if( !theType.empty() )
+      if(!theType.empty())
       {
-        auto&& countIter = std::find_if( mInstanceCountContainer.begin(),
-                                         mInstanceCountContainer.end(),
-                                         [theType] ( const InstanceCountPair& instance )
-                                                   { return instance.first == theType; } );
-        if( countIter != mInstanceCountContainer.end() )
+        auto&& countIter = std::find_if(mInstanceCountContainer.begin(),
+                                        mInstanceCountContainer.end(),
+                                        [theType](const InstanceCountPair& instance) { return instance.first == theType; });
+        if(countIter != mInstanceCountContainer.end())
         {
           (*countIter).second--;
         }
       }
-      mInstanceTypes.erase( iter );
+      mInstanceTypes.erase(iter);
       return;
     }
   }
 }
 
-std::size_t ObjectProfiler::GetMemorySize( const std::string& name, uint32_t count )
+std::size_t ObjectProfiler::GetMemorySize(const std::string& name, uint32_t count)
 {
   struct MemoryMemorySize
   {
@@ -142,22 +138,22 @@ std::size_t ObjectProfiler::GetMemorySize( const std::string& name, uint32_t cou
   };
   MemoryMemorySize memoryMemorySizes[] =
     {
-      { "Animation", ANIMATION_MEMORY_SIZE },
-      { "Constraint", CONSTRAINT_MEMORY_SIZE },
-      { "Actor", ACTOR_MEMORY_SIZE },
-      { "Layer", LAYER_MEMORY_SIZE },
-      { "CameraActor", CAMERA_ACTOR_MEMORY_SIZE },
-      { "Renderer", RENDERER_MEMORY_SIZE },
-      { "Geometry", GEOMETRY_MEMORY_SIZE },
-      { "PropertyBuffer", PROPERTY_BUFFER_MEMORY_SIZE },
-      { "TextureSet", TEXTURE_SET_MEMORY_SIZE },
-      { "Sampler", SAMPLER_MEMORY_SIZE },
-      { "Shader", SHADER_MEMORY_SIZE },
+      {"Animation", ANIMATION_MEMORY_SIZE},
+      {"Constraint", CONSTRAINT_MEMORY_SIZE},
+      {"Actor", ACTOR_MEMORY_SIZE},
+      {"Layer", LAYER_MEMORY_SIZE},
+      {"CameraActor", CAMERA_ACTOR_MEMORY_SIZE},
+      {"Renderer", RENDERER_MEMORY_SIZE},
+      {"Geometry", GEOMETRY_MEMORY_SIZE},
+      {"PropertyBuffer", PROPERTY_BUFFER_MEMORY_SIZE},
+      {"TextureSet", TEXTURE_SET_MEMORY_SIZE},
+      {"Sampler", SAMPLER_MEMORY_SIZE},
+      {"Shader", SHADER_MEMORY_SIZE},
     };
 
-  for( size_t i=0; i<sizeof(memoryMemorySizes)/sizeof(MemoryMemorySize); i++ )
+  for(size_t i = 0; i < sizeof(memoryMemorySizes) / sizeof(MemoryMemorySize); i++)
   {
-    if( memoryMemorySizes[i].name.compare(name) == 0 )
+    if(memoryMemorySizes[i].name.compare(name) == 0)
     {
       return count * memoryMemorySizes[i].memorySize;
     }
@@ -165,6 +161,6 @@ std::size_t ObjectProfiler::GetMemorySize( const std::string& name, uint32_t cou
   return 0;
 }
 
-} // Adaptor
-} // Internal
-} // Dali
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali