Some OffscreenApplication have some usage for LifecycleController signal.
But previously, we didn't attach this signal for app lifecycle correctly.
Now let we connect it so we can know the app's lifecycle
Change-Id: I75a2757ea17fcf6e21041302923b83b5964a3a83
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
return Internal::GetImplementation(*this).TerminateSignal();
}
+OffscreenApplication::OffscreenApplicationSignalType& OffscreenApplication::PauseSignal()
+{
+ return Internal::GetImplementation(*this).PauseSignal();
+}
+
+OffscreenApplication::OffscreenApplicationSignalType& OffscreenApplication::ResumeSignal()
+{
+ return Internal::GetImplementation(*this).ResumeSignal();
+}
+
+OffscreenApplication::OffscreenApplicationSignalType& OffscreenApplication::ResetSignal()
+{
+ return Internal::GetImplementation(*this).ResetSignal();
+}
+
+OffscreenApplication::OffscreenApplicationSignalType& OffscreenApplication::LanguageChangedSignal()
+{
+ return Internal::GetImplementation(*this).LanguageChangedSignal();
+}
+
OffscreenApplication::OffscreenApplication(Internal::OffscreenApplication* offscreenApplication)
: BaseHandle(offscreenApplication)
{
Any GetFrameworkContext() const;
public: // Signals
- /**
+ /**
* @brief Signal to notify the client when the application is ready to be initialized
*
* @note OffscreenApplication::Start() should be called to be initialized
*/
OffscreenApplicationSignalType& TerminateSignal();
+ /**
+ * @brief Signal to notify the user when the application is about to be paused
+ *
+ * @return The signal
+ */
+ OffscreenApplicationSignalType& PauseSignal();
+
+ /**
+ * @brief Signal to notify the user when the application is about to be resumed
+ *
+ * @return The signal
+ */
+ OffscreenApplicationSignalType& ResumeSignal();
+
+ /**
+ * @brief Signal to notify the user when the application is about to be reinitialized
+ *
+ * @return The signal
+ */
+ OffscreenApplicationSignalType& ResetSignal();
+
+ /**
+ * @brief Signal to notify the user when the application is about to be language is changed on the device.
+ *
+ * @return The signal
+ */
+ OffscreenApplicationSignalType& LanguageChangedSignal();
+
public: // Not intended for application developers
/**
* @brief Internal constructor
#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>
{
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)
// Start the adaptor
mAdaptor->Start();
+ Dali::OffscreenApplication application(this);
mInitSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnInit);
mAdaptor->NotifySceneCreated();
}
void OffscreenApplication::OnTerminate()
{
+ Dali::OffscreenApplication application(this);
mTerminateSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnTerminate);
// Stop the adaptor
mAdaptor->Stop();
mDefaultWindow.Reset();
}
+void OffscreenApplication::OnPause()
+{
+ Dali::OffscreenApplication application(this);
+ mPauseSignal.Emit();
+ EmitLifecycleControllerSignal(&Internal::Adaptor::LifecycleController::OnPause);
+}
+
+void OffscreenApplication::OnResume()
+{
+ 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();
return mTerminateSignal;
}
+ /**
+ * @copydoc Dali::OffscreenApplication::PauseSignal()
+ */
+ OffscreenApplicationSignalType& PauseSignal()
+ {
+ return mPauseSignal;
+ }
+
+ /**
+ * @copydoc Dali::OffscreenApplication::ResumeSignal()
+ */
+ OffscreenApplicationSignalType& ResumeSignal()
+ {
+ return mResumeSignal;
+ }
+
+ /**
+ * @copydoc Dali::OffscreenApplication::ResetSignal()
+ */
+ OffscreenApplicationSignalType& ResetSignal()
+ {
+ return mResetSignal;
+ }
+
+ /**
+ * @copydoc Dali::OffscreenApplication::LanguageChangedSignal()
+ */
+ OffscreenApplicationSignalType& LanguageChangedSignal()
+ {
+ return mLanguageChangedSignal;
+ }
+
public: // From Framework::Observer
/**
* Called when the framework is initialised.
*/
void OnTerminate() override;
+ /**
+ * Called when the framework is paused.
+ */
+ void OnPause() override;
+
+ /**
+ * Called when the framework resumes from a paused state.
+ */
+ void OnResume() override;
+
+ /**
+ * Called when the framework informs the application that it should reset itself.
+ */
+ void OnReset() override;
+
+ /**
+ * Called when the framework informs the application that the language of the device has changed.
+ */
+ void OnLanguageChanged() override;
+
private:
/**
* Private constructor
OffscreenApplicationSignalType mInitSignal;
OffscreenApplicationSignalType mTerminateSignal;
+ OffscreenApplicationSignalType mPauseSignal;
+ OffscreenApplicationSignalType mResumeSignal;
+ OffscreenApplicationSignalType mResetSignal;
+ OffscreenApplicationSignalType mLanguageChangedSignal;
};
inline OffscreenApplication& GetImplementation(Dali::OffscreenApplication& offscreenApplication)