Merge "Trace use scope macro instead of begin-end" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
index 14f62fa..42b9309 100644 (file)
@@ -34,6 +34,7 @@
 #include <dali/integration-api/input-options.h>
 #include <dali/integration-api/processor-interface.h>
 #include <dali/integration-api/profiling.h>
+#include <dali/integration-api/trace.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/events/wheel-event.h>
 #include <dali/public-api/object/any.h>
@@ -91,6 +92,7 @@ namespace
 {
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
 } // unnamed namespace
 
 Dali::Adaptor* Adaptor::New(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode)
@@ -187,6 +189,14 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory)
     mObjectProfiler = new ObjectProfiler(mCore->GetObjectRegistry(), timeInterval);
   }
 
+  const uint32_t poolTimeInterval = mEnvironmentOptions->GetMemoryPoolInterval();
+  if(0u < poolTimeInterval)
+  {
+    mMemoryPoolTimer = Dali::Timer::New(poolTimeInterval * 1000);
+    mMemoryPoolTimer.TickSignal().Connect(mMemoryPoolTimerSlotDelegate, &Adaptor::MemoryPoolTimeout);
+    mMemoryPoolTimer.Start();
+  }
+
   mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent(MakeCallback(this, &Adaptor::ProcessCoreEvents), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
 
   mDisplayConnection = Dali::DisplayConnection::New(*mGraphics, defaultWindow->GetSurface()->GetSurfaceType());
@@ -302,7 +312,6 @@ void Adaptor::Initialize(GraphicsFactory& graphicsFactory)
     if(0 != dir_err && errno != EEXIST)
     {
       DALI_LOG_ERROR("Error creating system cache directory: %s!\n", systemCachePath.c_str());
-      exit(1);
     }
   }
 
@@ -908,21 +917,15 @@ void Adaptor::ProcessCoreEvents()
 {
   if(mCore)
   {
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
+
     if(mPerformanceInterface)
     {
       mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_START);
     }
 
-#ifndef DALI_PROFILE_UBUNTU
-    DALI_LOG_RELEASE_INFO("Start ProcessEvents\n");
-#endif
-
     mCore->ProcessEvents();
 
-#ifndef DALI_PROFILE_UBUNTU
-    DALI_LOG_RELEASE_INFO("End ProcessEvents\n");
-#endif
-
     if(mPerformanceInterface)
     {
       mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_END);
@@ -1137,6 +1140,15 @@ bool Adaptor::IsMultipleWindowSupported() const
   return mConfigurationManager->IsMultipleWindowSupported();
 }
 
+int32_t Adaptor::GetRenderThreadId() const
+{
+  if(mThreadController)
+  {
+    return mThreadController->GetThreadId();
+  }
+  return 0;
+}
+
 void Adaptor::RequestUpdateOnce()
 {
   if(mThreadController)
@@ -1234,6 +1246,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor,
   mKernelTracer(),
   mSystemTracer(),
   mObjectProfiler(nullptr),
+  mMemoryPoolTimerSlotDelegate(this),
   mSocketFactory(),
   mMutex(),
   mThreadMode(threadMode),
@@ -1281,6 +1294,12 @@ void Adaptor::RemoveIdleEnterer(CallbackBase* callback)
   mCallbackManager->RemoveIdleEntererCallback(callback);
 }
 
+bool Adaptor::MemoryPoolTimeout()
+{
+  mCore->LogMemoryPools();
+  return true; // Keep logging forever
+}
+
 } // namespace Adaptor
 
 } // namespace Internal