This patch is to support pre-initialized using Tizen Preloader for UI Threading.
Next step, the related feature will be refactoring using factory pattern.
Change-Id: Ib143b02906970fb878ef21c423e5aaebad3d967b
return true;
}
+/**
+ * Impl for Pre-Initailized using UI Thread.
+ */
+struct UIThreadLoader::Impl
+{
+ // Constructor
+
+ Impl(void *data)
+ {
+ }
+
+ ~Impl()
+ {
+ }
+
+ void Run(Runner runner)
+ {
+ }
+
+private:
+ // Undefined
+ Impl(const Impl& impl);
+ Impl& operator=(const Impl& impl);
+};
+
+/**
+ * UI Thread loader to support Pre-Initailized using UI Thread.
+ */
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)
+: mArgc(argc),
+ mArgv(argv),
+ mImpl(nullptr)
+{
+}
+
+UIThreadLoader::~UIThreadLoader()
+{
+}
+
+void UIThreadLoader::Run(Runner runner)
+{
+}
+
} // namespace Adaptor
} // namespace Internal
return true;
}
+/**
+ * Impl for Pre-Initailized using UI Thread.
+ */
+struct UIThreadLoader::Impl
+{
+ // Constructor
+
+ Impl(void *data)
+ {
+ }
+
+ ~Impl()
+ {
+ }
+
+ void Run(Runner runner)
+ {
+ }
+
+private:
+ // Undefined
+ Impl(const Impl& impl);
+ Impl& operator=(const Impl& impl);
+};
+
+/**
+ * UI Thread loader to support Pre-Initailized using UI Thread.
+ */
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)
+: mArgc(argc),
+ mArgv(argv),
+ mImpl(nullptr)
+{
+}
+
+UIThreadLoader::~UIThreadLoader()
+{
+}
+
+void UIThreadLoader::Run(Runner runner)
+{
+}
+
} // namespace Adaptor
} // namespace Internal
{
if(!gPreInitializedApplication)
{
+ char* retEnv = std::getenv("TIZEN_UI_THREAD");
+ bool isUseUIThread = false;
+ if(retEnv)
+ {
+ std::string uiThreadEnv = retEnv;
+ std::string enabledString = "true";
+ if(uiThreadEnv == enabledString)
+ {
+ isUseUIThread = true;
+ }
+ }
+
Dali::TextAbstraction::FontClientPreInitialize();
WindowData windowData;
- gPreInitializedApplication = new Application(argc, argv, "", Framework::NORMAL, false, windowData);
+ gPreInitializedApplication = new Application(argc, argv, "", Framework::NORMAL, isUseUIThread, windowData);
gPreInitializedApplication->mLaunchpadState = Launchpad::PRE_INITIALIZED;
- gPreInitializedApplication->CreateWindow(); // Only create window
+ if(isUseUIThread)
+ {
+ DALI_LOG_RELEASE_INFO("PRE_INITIALIZED with UI Threading");
+ gPreInitializedApplication->mUIThreadLoader = new UIThreadLoader(argc, argv);
+ gPreInitializedApplication->mUIThreadLoader->Run([&](){gPreInitializedApplication->CreateWindow();});
+ }
+ else
+ {
+ DALI_LOG_RELEASE_INFO("Only PRE_INITIALIZED");
+ gPreInitializedApplication->CreateWindow(); // Only create window
+ }
+
+
}
}
mDefaultWindowType(windowData.GetWindowType()),
mUseUiThread(useUiThread),
mIsSystemInitialized(false),
- mSlotDelegate(this)
+ mSlotDelegate(this),
+ mUIThreadLoader(nullptr)
{
// Set mName from command-line args
if(argc && (*argc > 0))
WindowSystem::Shutdown();
}
}
+ else
+ {
+ if(mUIThreadLoader)
+ {
+ delete mUIThreadLoader;
+ }
+ }
}
void Application::StoreWindowPositionSize(PositionSize positionSize)
windowData.SetTransparency(mMainWindowMode);
windowData.SetWindowType(mDefaultWindowType);
+ DALI_LOG_RELEASE_INFO("Create Default Window");
+
WindowSystem::Initialize();
mIsSystemInitialized = true;
// If an application was pre-initialized, a window was made in advance
if(mLaunchpadState == Launchpad::NONE)
{
+ DALI_LOG_RELEASE_INFO("default Window is created in standalone");
CreateWindow();
}
SlotDelegate<Application> mSlotDelegate;
+ UIThreadLoader* mUIThreadLoader;
static ApplicationPtr gPreInitializedApplication;
};
private:
// Undefined
- Framework(const Framework&) = delete;
+ Framework(const Framework&) = delete;
Framework& operator=(Framework&) = delete;
protected:
bool mRunning;
};
+class UIThreadLoader
+{
+public:
+ using Runner = std::function<void()>;
+
+ /**
+ * Constructor
+ * @param[in] argc A pointer to the number of arguments.
+ * @param[in] argv A pointer the the argument list.
+ */
+ UIThreadLoader(int* argc, char*** argv);
+
+ /**
+ * Destructor
+ */
+ ~UIThreadLoader();
+
+public:
+ /**
+ * Runs the main loop of framework
+ */
+ void Run(Runner runner);
+
+private:
+ // Undefined
+ UIThreadLoader(const UIThreadLoader&);
+ UIThreadLoader& operator=(UIThreadLoader&);
+
+private:
+ int* mArgc;
+ char*** mArgv;
+
+private: // impl members
+ struct Impl;
+ Impl* mImpl;
+};
+
} // namespace Adaptor
} // namespace Internal
/*
- * Copyright (c) 2015 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.
mImpl->Quit();
}
+/**
+ * Impl for Pre-Initailized using UI Thread.
+ */
+struct UIThreadLoader::Impl
+{
+ // Constructor
+
+ Impl(void *data)
+ {
+ }
+
+ ~Impl()
+ {
+ }
+
+ void Run(Runner runner)
+ {
+ }
+
+private:
+ // Undefined
+ Impl(const Impl& impl);
+ Impl& operator=(const Impl& impl);
+};
+
+/**
+ * UI Thread loader to support Pre-Initailized using UI Thread.
+ */
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)
+: mArgc(argc),
+ mArgv(argv),
+ mImpl(nullptr)
+{
+}
+
+UIThreadLoader::~UIThreadLoader()
+{
+}
+
+void UIThreadLoader::Run(Runner runner)
+{
+}
+
} // namespace Adaptor
} // namespace Internal
return true;
}
+/**
+ * Impl for Pre-Initailized using UI Thread.
+ */
+struct UIThreadLoader::Impl
+{
+ // Constructor
+
+ Impl(void *data)
+ {
+ }
+
+ ~Impl()
+ {
+ }
+
+ void Run(Runner runner)
+ {
+ }
+
+private:
+ // Undefined
+ Impl(const Impl& impl);
+ Impl& operator=(const Impl& impl);
+};
+
+/**
+ * UI Thread loader to support Pre-Initailized using UI Thread.
+ */
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)
+: mArgc(argc),
+ mArgv(argv),
+ mImpl(nullptr)
+{
+}
+
+UIThreadLoader::~UIThreadLoader()
+{
+}
+
+void UIThreadLoader::Run(Runner runner)
+{
+}
+
} // namespace Adaptor
} // namespace Internal
#include <widget_base.h>
#include <app_core_ui_base.hh>
#include <app_event_internal.hh>
+#include <app_core_ui_thread_base.hh>
// CONDITIONAL INCLUDES
#ifdef APPCORE_WATCH_AVAILABLE
return mImpl->GetRegion();
}
+/**
+ * Impl for Pre-Initailized using UI Thread.
+ */
+struct UIThreadLoader::Impl
+{
+ // Constructor
+ Impl(void *data)
+ {
+ mUIThreadLoader = static_cast<UIThreadLoader*>(data);
+ mAppCoreUiThreadBase = new AppCoreUiThreadBase();
+ print_log(DLOG_INFO, "DALI", "%s: %s(%d) > Create mAppCoreUiThreadBase(%p)", __MODULE__, __func__, __LINE__, mAppCoreUiThreadBase);
+ }
+
+ // Destructor
+ ~Impl()
+ {
+ if(mAppCoreUiThreadBase)
+ {
+ mAppCoreUiThreadBase->Exit();
+ delete mAppCoreUiThreadBase;
+ }
+ }
+
+ /**
+ * Runs to work create window in UI thread when application is pre-initialized.
+ */
+ void Run(Runner runner)
+ {
+ mAppCoreUiThreadBase->Post(runner);
+ mAppCoreUiThreadBase->Run(*(mUIThreadLoader->mArgc), *(mUIThreadLoader->mArgv));
+ }
+
+private:
+ // Undefined
+ Impl(const Impl& impl);
+ Impl& operator=(const Impl& impl);
+
+ // Data
+ AppCoreUiThreadBase* mAppCoreUiThreadBase;
+ UIThreadLoader* mUIThreadLoader;
+};
+
+/**
+ * UI Thread loader to support Pre-Initailized using UI Thread.
+ */
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)
+: mArgc(argc),
+ mArgv(argv),
+ mImpl(nullptr)
+{
+ if(mArgc == nullptr || mArgv == nullptr)
+ {
+ mArgc = const_cast<int*>(&gTizenDummyArgc);
+ mArgv = const_cast<char***>(reinterpret_cast<const char***>(&gTizenDummyArgv));
+ }
+
+ mImpl = new Impl(this);
+}
+
+UIThreadLoader::~UIThreadLoader()
+{
+ if(mImpl)
+ {
+ delete mImpl;
+ }
+}
+
+/**
+ * Runs to work create window in UI thread when application is pre-initialized.
+ */
+void UIThreadLoader::Run(Runner runner)
+{
+ mImpl->Run(runner);
+}
+
} // namespace Adaptor
} // namespace Internal
XInitThreads();
}
+/**
+ * Impl for Pre-Initailized using UI Thread.
+ */
+struct UIThreadLoader::Impl
+{
+ // Constructor
+ Impl(void *data)
+ {
+ }
+
+ ~Impl()
+ {
+ }
+
+ void Run(Runner runner)
+ {
+ }
+
+private:
+ // Undefined
+ Impl(const Impl& impl);
+ Impl& operator=(const Impl& impl);
+};
+
+/**
+ * UI Thread loader to support Pre-Initailized using UI Thread.
+ */
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)
+: mArgc(argc),
+ mArgv(argv),
+ mImpl(nullptr)
+{
+}
+
+UIThreadLoader::~UIThreadLoader()
+{
+}
+
+void UIThreadLoader::Run(Runner runner)
+{
+}
+
} // namespace Adaptor
} // namespace Internal
mObserver.OnTerminate();\r
}\r
\r
+/**\r
+ * Impl for Pre-Initailized using UI Thread.\r
+ */\r
+struct UIThreadLoader::Impl\r
+{\r
+ // Constructor\r
+ Impl(void *data)\r
+ {\r
+ }\r
+\r
+ ~Impl()\r
+ {\r
+ }\r
+\r
+ /**\r
+ * Runs the main loop of framework\r
+ */\r
+ void Run(Runner runner)\r
+ {\r
+ }\r
+\r
+private:\r
+ // Undefined\r
+ Impl(const Impl& impl);\r
+ Impl& operator=(const Impl& impl);\r
+};\r
+\r
+/**\r
+ * UI Thread loader to support Pre-Initailized using UI Thread.\r
+ */\r
+UIThreadLoader::UIThreadLoader(int* argc, char*** argv)\r
+: mArgc(argc),\r
+ mArgv(argv),\r
+ mImpl(nullptr)\r
+{\r
+}\r
+\r
+UIThreadLoader::~UIThreadLoader()\r
+{\r
+}\r
+\r
+void UIThreadLoader::Run(Runner runner)\r
+{\r
+}\r
+\r
} // namespace Adaptor\r
\r
} // namespace Internal\r