#include <dali/internal/offscreen/common/offscreen-application-impl.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/environment-variable.h>
#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/integration-api/adaptor-framework/native-render-surface.h>
#include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/framework-factory.h>
+#include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
#include <dali/internal/adaptor/common/thread-controller-interface.h>
#include <dali/internal/offscreen/common/offscreen-window-impl.h>
+#include <dali/internal/system/common/environment-variables.h>
#include <dali/internal/window-system/common/window-system.h>
namespace Dali
{
namespace Internal
{
+namespace
+{
+void EmitLifecycleControllerSignal(void (Internal::Adaptor::LifecycleController::*member)(Dali::Application&))
+{
+ Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
+ if(DALI_LIKELY(lifecycleController))
+ {
+ Dali::Application dummyApplication;
+ (GetImplementation(lifecycleController).*member)(dummyApplication);
+ }
+}
+} // namespace
using RenderMode = Dali::OffscreenApplication::RenderMode;
IntrusivePtr<OffscreenApplication> OffscreenApplication::New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode)
OffscreenApplication::OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode)
{
- Dali::Internal::Adaptor::WindowSystem::Initialize();
+ // Disable partial update
+ EnvironmentVariable::SetEnvironmentVariable(DALI_ENV_DISABLE_PARTIAL_UPDATE, "1");
+
+ // Disable ATSPI
+ Dali::Accessibility::Bridge::DisableAutoInit();
+
+ // Now we assume separated main loop for the offscreen application
+ mFrameworkFactory = std::unique_ptr<Adaptor::FrameworkFactory>(Dali::Internal::Adaptor::CreateFrameworkFactory());
+ mFramework = mFrameworkFactory->CreateFramework(Internal::Adaptor::FrameworkBackend::GLIB, *this, *this, nullptr, nullptr, Adaptor::Framework::NORMAL, false);
// Generate a default window
IntrusivePtr<Internal::OffscreenWindow> impl = Internal::OffscreenWindow::New(width, height, surface, isTranslucent);
OffscreenApplication::~OffscreenApplication()
{
- Dali::Internal::Adaptor::WindowSystem::Shutdown();
}
-void OffscreenApplication::Start()
+void OffscreenApplication::MainLoop()
+{
+ mFramework->Run();
+}
+
+void OffscreenApplication::Quit()
+{
+ // Actually quit the application.
+ Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle(MakeCallback(this, &OffscreenApplication::QuitFromMainLoop), false);
+}
+
+Dali::OffscreenWindow OffscreenApplication::GetWindow()
+{
+ return mDefaultWindow;
+}
+
+void OffscreenApplication::RenderOnce()
+{
+ mAdaptor->RenderOnce();
+}
+
+Any OffscreenApplication::GetFrameworkContext() const
+{
+ return mFramework->GetMainLoopContext();
+}
+
+void OffscreenApplication::OnInit()
{
// Start the adaptor
mAdaptor->Start();
- Dali::OffscreenApplication handle(this);
+ Dali::OffscreenApplication application(this);
mInitSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnInit);
+
mAdaptor->NotifySceneCreated();
}
-void OffscreenApplication::Stop()
+void OffscreenApplication::OnTerminate()
{
+ Dali::OffscreenApplication application(this);
+ mTerminateSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnTerminate);
+
// Stop the adaptor
mAdaptor->Stop();
- Dali::OffscreenApplication handle(this);
- mTerminateSignal.Emit();
+ mDefaultWindow.Reset();
}
-Dali::OffscreenWindow OffscreenApplication::GetWindow()
+void OffscreenApplication::OnPause()
{
- return mDefaultWindow;
+ Dali::OffscreenApplication application(this);
+ mPauseSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnPause);
}
-void OffscreenApplication::RenderOnce()
+void OffscreenApplication::OnResume()
{
- mAdaptor->RenderOnce();
+ Dali::OffscreenApplication application(this);
+ mResumeSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnResume);
+
+ // DALi just delivers the framework Resume event to the application.
+ // Resuming DALi core only occurs on the Window Show framework event
+
+ // Trigger processing of events queued up while paused
+ Internal::Adaptor::CoreEventInterface& coreEventInterface = Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor);
+ coreEventInterface.ProcessCoreEvents();
+}
+
+void OffscreenApplication::OnReset()
+{
+ /*
+ * usually, reset callback was called when a caller request to launch this application via aul.
+ * because Application class already handled initialization in OnInit(), OnReset do nothing.
+ */
+ Dali::OffscreenApplication application(this);
+ mResetSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnReset);
+}
+
+void OffscreenApplication::OnLanguageChanged()
+{
+ mAdaptor->NotifyLanguageChanged();
+
+ Dali::OffscreenApplication application(this);
+ mLanguageChangedSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnLanguageChanged);
+}
+
+void OffscreenApplication::QuitFromMainLoop()
+{
+ mAdaptor->Stop();
+
+ mFramework->Quit();
+ // This will trigger OnTerminate(), below, after the main loop has completed.
}
} // namespace Internal