X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Foffscreen%2Fcommon%2Foffscreen-application-impl.cpp;h=f1fc2e72cd5445259dde12599d7e4db6bef973e5;hb=1b4a1e578fd53340e38b919b8f3459ec1a09462f;hp=396dbc49889a0fbdbf1b4893668f0f286605996c;hpb=dd7e0c329b95a8142d266bf567cebbb0375176ec;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/offscreen/common/offscreen-application-impl.cpp b/dali/internal/offscreen/common/offscreen-application-impl.cpp index 396dbc4..f1fc2e7 100644 --- a/dali/internal/offscreen/common/offscreen-application-impl.cpp +++ b/dali/internal/offscreen/common/offscreen-application-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 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. @@ -19,66 +19,165 @@ #include // INTERNAL INCLUDES -#include -#include -#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include 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 ) +IntrusivePtr OffscreenApplication::New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, RenderMode renderMode) { - IntrusivePtr< OffscreenApplication > offscreenApplication = new OffscreenApplication( width, height, surface, isTranslucent, renderMode ); + IntrusivePtr offscreenApplication = new OffscreenApplication(width, height, surface, isTranslucent, renderMode); return offscreenApplication; } -OffscreenApplication::OffscreenApplication( 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) { + // 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(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 ); - mDefaultWindow = Dali::OffscreenWindow( impl.Get() ); + IntrusivePtr impl = Internal::OffscreenWindow::New(width, height, surface, isTranslucent); + mDefaultWindow = Dali::OffscreenWindow(impl.Get()); - mAdaptor.reset( Dali::Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( impl.Get() ), impl->GetSurface(), NULL, - renderMode == RenderMode::AUTO ? Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED ) ); + mAdaptor.reset(Dali::Internal::Adaptor::Adaptor::New(Dali::Integration::SceneHolder(impl.Get()), impl->GetSurface(), NULL, renderMode == RenderMode::AUTO ? Dali::Internal::Adaptor::ThreadMode::NORMAL : Dali::Internal::Adaptor::ThreadMode::RUN_IF_REQUESTED)); // Initialize default window - impl->Initialize( true ); + impl->Initialize(true); +} + +OffscreenApplication::~OffscreenApplication() +{ +} + +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(); } -void OffscreenApplication::Start() +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