Load image loader plugin if requested
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
index b7de74f..d023730 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.
@@ -67,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>
@@ -75,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>
 
@@ -93,6 +95,8 @@ 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)
@@ -404,10 +408,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();
@@ -429,7 +430,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)
   {
@@ -548,7 +554,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;
@@ -917,17 +928,15 @@ void Adaptor::ProcessCoreEvents()
 {
   if(mCore)
   {
+    DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
+
     if(mPerformanceInterface)
     {
       mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_START);
     }
 
-    DALI_TRACE_BEGIN(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
-
     mCore->ProcessEvents();
 
-    DALI_TRACE_END(gTraceFilter, "DALI_PROCESS_CORE_EVENTS");
-
     if(mPerformanceInterface)
     {
       mPerformanceInterface->AddMarker(PerformanceInterface::PROCESS_EVENTS_END);
@@ -1142,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)