X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fapplication-impl.cpp;h=cd05c9537803ec7a6e94e5528c092e92197023fb;hb=788496092f35a4bf77163b29aad5f9d64a0b7b92;hp=e43871f6ad6a0bcd1fdc5980ff30832730a65ff4;hpb=f9f2fa4353e48c8320d7d36c6a2b8789bbbaa505;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index e43871f..cd05c95 100644 --- a/adaptors/common/application-impl.cpp +++ b/adaptors/common/application-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -52,14 +53,15 @@ ApplicationPtr Application::New( char **argv[], const std::string& stylesheet, Dali::Application::WINDOW_MODE windowMode, + const PositionSize& positionSize, Framework::Type applicationType) { - ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode, applicationType ) ); + ApplicationPtr application ( new Application (argc, argv, stylesheet, windowMode, positionSize, applicationType ) ); return application; } Application::Application( int* argc, char** argv[], const std::string& stylesheet, - Dali::Application::WINDOW_MODE windowMode, Framework::Type applicationType ) + Dali::Application::WINDOW_MODE windowMode, const PositionSize& positionSize, Framework::Type applicationType ) : mInitSignal(), mTerminateSignal(), mPauseSignal(), @@ -82,6 +84,7 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mName(), mStylesheet( stylesheet ), mEnvironmentOptions(), + mWindowPositionSize( positionSize ), mSlotDelegate( this ) { // Get mName from environment options @@ -94,35 +97,39 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mCommandLineOptions = new CommandLineOptions(argc, argv); mFramework = new Framework( *this, argc, argv, applicationType ); + mUseRemoteSurface = (applicationType == Framework::WATCH); } Application::~Application() { mSingletonService.UnregisterAll(); - delete mFramework; - delete mCommandLineOptions; - delete mAdaptor; mWindow.Reset(); + delete mAdaptor; + delete mCommandLineOptions; + delete mFramework; } void Application::CreateWindow() { - PositionSize windowPosition(0, 0, 0, 0); // this will use full screen - - if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 ) - { - // Command line options override environment options and full screen - windowPosition = PositionSize( 0, 0, mCommandLineOptions->stageWidth, mCommandLineOptions->stageHeight ); - } - else if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() ) + if( mWindowPositionSize.width == 0 && mWindowPositionSize.height == 0 ) { - // Environment options override full screen functionality if command line arguments not provided - windowPosition = PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ); + if( mCommandLineOptions->stageWidth > 0 && mCommandLineOptions->stageHeight > 0 ) + { + // Command line options override environment options and full screen + mWindowPositionSize.width = mCommandLineOptions->stageWidth; + mWindowPositionSize.height = mCommandLineOptions->stageHeight; + } + else if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() ) + { + // Environment options override full screen functionality if command line arguments not provided + mWindowPositionSize.width = mEnvironmentOptions.GetWindowWidth(); + mWindowPositionSize.height = mEnvironmentOptions.GetWindowHeight(); + } } const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName(); - mWindow = Dali::Window::New( windowPosition, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT ); + mWindow = Dali::Window::New( mWindowPositionSize, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT ); // Quit the application when the window is closed GetImplementation( mWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit ); @@ -135,6 +142,8 @@ void Application::CreateAdaptor() 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) @@ -165,17 +174,15 @@ void Application::QuitFromMainLoop() // This will trigger OnTerminate(), below, after the main loop has completed. } -void Application::OnInit() +void Application::DoInit() { - mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); - CreateWindow(); CreateAdaptor(); // Run the adaptor mAdaptor->Start(); - // Check if user requires no vsyncing and set on X11 Adaptor + // Check if user requires no vsyncing and set Adaptor if (mCommandLineOptions->noVSyncOnRender) { mAdaptor->SetUseHardwareVSync(false); @@ -196,6 +203,44 @@ void Application::OnInit() { Dali::StyleMonitor::Get().SetTheme( mStylesheet ); } +} + +void Application::DoStart() +{ + mAdaptor->NotifySceneCreated(); +} + +void Application::DoTerminate() +{ + if( mAdaptor ) + { + // Ensure that the render-thread is not using the surface(window) after we delete it + mAdaptor->Stop(); + } + + mWindow.Reset(); +} + +void Application::DoPause() +{ + mAdaptor->Pause(); +} + +void Application::DoResume() +{ + mAdaptor->Resume(); +} + +void Application::DoLanguageChange() +{ + mAdaptor->NotifyLanguageChanged(); +} + +void Application::OnInit() +{ + mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); + + DoInit(); // Wire up the LifecycleController Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get(); @@ -211,7 +256,7 @@ void Application::OnInit() Dali::Application application(this); mInitSignal.Emit( application ); - mAdaptor->NotifySceneCreated(); + DoStart(); } void Application::OnTerminate() @@ -222,18 +267,14 @@ void Application::OnTerminate() 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(); + DoTerminate(); } 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 ); } @@ -244,7 +285,9 @@ void Application::OnResume() // This ensures we do not just redraw the last frame before pausing if that's not required Dali::Application application(this); mResumeSignal.Emit( application ); - mAdaptor->Resume(); + + // DALi just delivers the framework Resume event to the application. + // Resuming DALi core only occurs on the Window Show framework event } void Application::OnReset() @@ -265,7 +308,7 @@ void Application::OnAppControl(void *data) void Application::OnLanguageChanged() { - mAdaptor->NotifyLanguageChanged(); + DoLanguageChange(); Dali::Application application(this); mLanguageChangedSignal.Emit( application ); } @@ -332,17 +375,24 @@ float Application::GetStereoBase() const } -void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name) +void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name ) { - Dali::Window newWindow = Dali::Window::New( windowPosition, name, mWindowMode == Dali::Application::TRANSPARENT ); + Dali::Window newWindow = Dali::Window::New( positionSize, name, mWindowMode == Dali::Application::TRANSPARENT ); Window& windowImpl = GetImplementation(newWindow); windowImpl.SetAdaptor(*mAdaptor); newWindow.ShowIndicator(Dali::Window::INVISIBLE); Dali::RenderSurface* renderSurface = windowImpl.GetSurface(); Any nativeWindow = newWindow.GetNativeHandle(); + Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SurfaceSizeChanged( Dali::Adaptor::SurfaceSize( positionSize.width, positionSize.height ) ); Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface); mWindow = newWindow; + mWindowPositionSize = positionSize; +} + +std::string Application::GetResourcePath() +{ + return Internal::Adaptor::Framework::GetResourcePath(); } } // namespace Adaptor