X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fapplication-impl.cpp;h=bd885e6f09956d781be4e84b9a301a66aae7df18;hb=66f6b93f1a7b09f6023e8278bed7cafc2a0e877c;hp=6a98391918f9cc78bfac0da67e97c0586a4795a7;hpb=ead73b3116bb2a42386cdeb9ff421b9a37f32ec5;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index 6a98391..bd885e6 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -51,13 +51,15 @@ ApplicationPtr Application::New( int* argc, char **argv[], const std::string& stylesheet, - Dali::Application::WINDOW_MODE windowMode) + Dali::Application::WINDOW_MODE windowMode, + Framework::Type applicationType) { - ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode ) ); + ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode, applicationType ) ); return application; } -Application::Application( int* argc, char** argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode ) +Application::Application( int* argc, char** argv[], const std::string& stylesheet, + Dali::Application::WINDOW_MODE windowMode, Framework::Type applicationType ) : mInitSignal(), mTerminateSignal(), mPauseSignal(), @@ -71,6 +73,7 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mMemoryLowSignal(), mEventLoop( NULL ), mFramework( NULL ), + mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ), mCommandLineOptions( NULL ), mSingletonService( SingletonService::New() ), mAdaptor( NULL ), @@ -78,18 +81,20 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mWindowMode( windowMode ), mName(), mStylesheet( stylesheet ), - mInitialized( false ), + mEnvironmentOptions(), mSlotDelegate( this ) { - // Copy mName from command-line args - if( argc && ( *argc > 0 ) ) + // Get mName from environment options + mName = mEnvironmentOptions.GetWindowName(); + if( mName.empty() && argc && ( *argc > 0 ) ) { + // Set mName from command-line args if environment option not set mName = (*argv)[0]; } mCommandLineOptions = new CommandLineOptions(argc, argv); - - mFramework = new Framework(*this, argc, argv, mName); + mFramework = new Framework( *this, argc, argv, applicationType ); + mUseRemoteSurface = (applicationType == Framework::WATCH); } Application::~Application() @@ -99,6 +104,7 @@ Application::~Application() delete mFramework; delete mCommandLineOptions; delete mAdaptor; + mWindow.Reset(); } @@ -108,20 +114,31 @@ void Application::CreateWindow() if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 ) { - // let the command line options over ride + // Command line options override environment options and full screen windowPosition = PositionSize( 0, 0, mCommandLineOptions->stageWidth, mCommandLineOptions->stageHeight ); } + else if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() ) + { + // Environment options override full screen functionality if command line arguments not provided + windowPosition = PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ); + } + + const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName(); + mWindow = Dali::Window::New( windowPosition, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT ); - mWindow = Dali::Window::New( windowPosition, mName, mWindowMode == Dali::Application::TRANSPARENT ); + // Quit the application when the window is closed + GetImplementation( mWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit ); } void Application::CreateAdaptor() { DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" ); - mAdaptor = &Dali::Adaptor::New( mWindow, mContextLossConfiguration ); + mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions ); mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize ); + + Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface ); } void Application::MainLoop(Dali::Configuration::ContextLoss configuration) @@ -148,12 +165,8 @@ void Application::QuitFromMainLoop() { mAdaptor->Stop(); - Dali::Application application(this); - mTerminateSignal.Emit( application ); - mFramework->Quit(); // This will trigger OnTerminate(), below, after the main loop has completed. - mInitialized = false; } void Application::OnInit() @@ -161,9 +174,9 @@ void Application::OnInit() mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); CreateWindow(); - CreateAdaptor(); - // Run the adaptor + // Start the adaptor + CreateAdaptor(); mAdaptor->Start(); // Check if user requires no vsyncing and set on X11 Adaptor @@ -188,8 +201,6 @@ void Application::OnInit() Dali::StyleMonitor::Get().SetTheme( mStylesheet ); } - mInitialized = true; - // Wire up the LifecycleController Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get(); @@ -204,7 +215,7 @@ void Application::OnInit() Dali::Application application(this); mInitSignal.Emit( application ); - Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetCore().SceneCreated(); + mAdaptor->NotifySceneCreated(); } void Application::OnTerminate() @@ -212,22 +223,36 @@ void Application::OnTerminate() // we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously // delete the window as ecore_x has been destroyed by AppCore + Dali::Application application(this); + mTerminateSignal.Emit( application ); + + if( mAdaptor ) + { + // Ensure that the render-thread is not using the surface(window) after we delete it + mAdaptor->Stop(); + } + mWindow.Reset(); - mInitialized = false; } void Application::OnPause() { - mAdaptor->Pause(); + // A DALi app should handle Pause/Resume events. + // DALi just delivers the framework Pause event to the application, but not actually pause DALi core + // Pausing DALi core only occurs on the Window Hidden framework event Dali::Application application(this); mPauseSignal.Emit( application ); } void Application::OnResume() { - mAdaptor->Resume(); + // Emit the signal first so the application can queue any messages before we do an update/render + // This ensures we do not just redraw the last frame before pausing if that's not required Dali::Application application(this); mResumeSignal.Emit( application ); + + // DALi just delivers the framework Resume event to the application. + // Resuming DALi core only occurs on the Window Show framework event } void Application::OnReset() @@ -238,8 +263,6 @@ void Application::OnReset() */ Dali::Application application(this); mResetSignal.Emit( application ); - - mWindow.Raise(); } void Application::OnAppControl(void *data) @@ -326,6 +349,7 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string& Dali::RenderSurface* renderSurface = windowImpl.GetSurface(); Any nativeWindow = newWindow.GetNativeHandle(); + Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SurfaceSizeChanged( windowPosition ); Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface); mWindow = newWindow; }