[Tizen] Fix rendering occured unlimited if window size changed multiple
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
index 5084234..eb54486 100644 (file)
@@ -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.
@@ -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>
@@ -66,6 +67,7 @@
 #include <dali/internal/window-system/common/event-handler.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/window-system.h>
 
 #include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
 #include <dali/internal/system/common/logging.h>
@@ -74,6 +76,7 @@
 #include <dali/internal/imaging/common/image-loader.h>
 #include <dali/internal/system/common/locale-utils.h>
 
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
 #include <dali/internal/system/common/configuration-manager.h>
 #include <dali/internal/system/common/environment-variables.h>
 
@@ -91,6 +94,9 @@ namespace
 {
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+
+const char* ENABLE_IMAGE_LOADER_PLUGIN_ENV = "DALI_ENABLE_IMAGE_LOADER_PLUGIN";
 } // unnamed namespace
 
 Dali::Adaptor* Adaptor::New(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode)
@@ -302,7 +308,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);
     }
   }
 
@@ -395,10 +400,7 @@ void Adaptor::Start()
   dpiHor = dpiVer = 0;
 
   defaultWindow->GetSurface()->GetDpi(dpiHor, dpiVer);
-
-  // set the DPI value for font rendering
-  FontClient fontClient = FontClient::Get();
-  fontClient.SetDpi(dpiHor, dpiVer);
+  Dali::Internal::Adaptor::WindowSystem::SetDpi(dpiHor, dpiVer);
 
   // Initialize the thread controller
   mThreadController->Initialize();
@@ -420,7 +422,12 @@ void Adaptor::Start()
   ProcessCoreEvents(); // Ensure any startup messages are processed.
 
   // Initialize the image loader plugin
-  Internal::Adaptor::ImageLoaderPluginProxy::Initialize();
+  auto enablePluginString = Dali::EnvironmentVariable::GetEnvironmentVariable(ENABLE_IMAGE_LOADER_PLUGIN_ENV);
+  bool enablePlugin       = enablePluginString ? std::atoi(enablePluginString) : false;
+  if(enablePlugin)
+  {
+    Internal::Adaptor::ImageLoaderPluginProxy::Initialize();
+  }
 
   for(ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter)
   {
@@ -539,7 +546,12 @@ void Adaptor::Stop()
     }
 
     // Destroy the image loader plugin
-    Internal::Adaptor::ImageLoaderPluginProxy::Destroy();
+    auto enablePluginString = Dali::EnvironmentVariable::GetEnvironmentVariable(ENABLE_IMAGE_LOADER_PLUGIN_ENV);
+    bool enablePlugin       = enablePluginString ? std::atoi(enablePluginString) : false;
+    if(enablePlugin)
+    {
+      Internal::Adaptor::ImageLoaderPluginProxy::Destroy();
+    }
 
     delete mNotificationTrigger;
     mNotificationTrigger = NULL;
@@ -913,15 +925,11 @@ void Adaptor::ProcessCoreEvents()
       mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_START);
     }
 
-#if !defined(DALI_PROFILE_UBUNTU) && !defined(DALI_PROFILE_LIBUV_X11)
-    DALI_LOG_RELEASE_INFO("Start ProcessEvents\n");
-#endif
+    DALI_TRACE_BEGIN(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
 
     mCore->ProcessEvents();
 
-#if !defined(DALI_PROFILE_UBUNTU) && !defined(DALI_PROFILE_LIBUV_X11)
-    DALI_LOG_RELEASE_INFO("End ProcessEvents\n");
-#endif
+    DALI_TRACE_END(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
 
     if(mPerformanceInterface)
     {
@@ -930,7 +938,7 @@ void Adaptor::ProcessCoreEvents()
   }
 }
 
-void Adaptor::RequestUpdate(bool forceUpdate)
+void Adaptor::RequestUpdate()
 {
   switch(mState)
   {
@@ -942,11 +950,8 @@ void Adaptor::RequestUpdate(bool forceUpdate)
     case PAUSED:
     case PAUSED_WHILE_HIDDEN:
     {
-      if(forceUpdate)
-      {
-        // Update (and resource upload) without rendering
-        mThreadController->RequestUpdateOnce(UpdateMode::SKIP_RENDER);
-      }
+      // Update (and resource upload) without rendering
+      mThreadController->RequestUpdateOnce(UpdateMode::SKIP_RENDER);
       break;
     }
     default:
@@ -957,13 +962,13 @@ void Adaptor::RequestUpdate(bool forceUpdate)
   }
 }
 
-void Adaptor::RequestProcessEventsOnIdle(bool forceProcess)
+void Adaptor::RequestProcessEventsOnIdle()
 {
-  // Only request a notification if the Adaptor is actually running
-  // and we haven't installed the idle notification
-  if((!mNotificationOnIdleInstalled) && (RUNNING == mState || READY == mState || forceProcess))
+  // Only request a notification if we haven't installed the idle notification
+  // We want to run the processes even when paused
+  if(!mNotificationOnIdleInstalled && STOPPED != mState)
   {
-    mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), forceProcess);
+    mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), true);
   }
 }
 
@@ -1043,7 +1048,7 @@ void Adaptor::OnWindowHidden()
 void Adaptor::OnDamaged(const DamageArea& area)
 {
   // This is needed for the case where Dali window is partially obscured
-  RequestUpdate(false);
+  RequestUpdate();
 }
 
 void Adaptor::SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
@@ -1061,6 +1066,15 @@ void Adaptor::SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, Surfa
   ProcessCoreEvents();
 }
 
+void Adaptor::IncreaseSurfaceResizeCounter()
+{
+  // Nofify surface resizing before flushing event queue
+  if(mThreadController)
+  {
+    mThreadController->ResizeSurface();
+  }
+}
+
 void Adaptor::NotifySceneCreated()
 {
   GetCore().SceneCreated();
@@ -1137,6 +1151,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)