X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fapplication-impl.cpp;h=931ba1218e14ad72d5f0ff8eb87b99806155e18d;hb=84ee1bf494a3410025aa7c7f9cec38601e9aaeab;hp=fc4a03545220dfbf1cb7ca55eac38853814672c8;hpb=91db2b69ef43de259baa0069c925d558421ead71;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/application-impl.cpp b/adaptors/common/application-impl.cpp index fc4a035..931ba12 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. @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -51,13 +52,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(), @@ -91,18 +94,18 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee } mCommandLineOptions = new CommandLineOptions(argc, argv); - - mFramework = new Framework( *this, 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() @@ -134,6 +137,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) @@ -160,24 +165,19 @@ 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. } -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); @@ -199,6 +199,41 @@ void Application::OnInit() Dali::StyleMonitor::Get().SetTheme( mStylesheet ); } + 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(); @@ -212,8 +247,6 @@ void Application::OnInit() Dali::Application application(this); mInitSignal.Emit( application ); - - mAdaptor->NotifySceneCreated(); } void Application::OnTerminate() @@ -221,27 +254,26 @@ 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 - if( mAdaptor ) - { - // Ensure that the render-thread is not using the surface(window) after we delete it - mAdaptor->Stop(); - } + Dali::Application application(this); + mTerminateSignal.Emit( application ); - mWindow.Reset(); + DoTerminate(); } void Application::OnPause() { - mAdaptor->Pause(); + DoPause(); 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 ); + DoResume(); } void Application::OnReset() @@ -252,8 +284,6 @@ void Application::OnReset() */ Dali::Application application(this); mResetSignal.Emit( application ); - - mWindow.Raise(); } void Application::OnAppControl(void *data) @@ -264,7 +294,7 @@ void Application::OnAppControl(void *data) void Application::OnLanguageChanged() { - mAdaptor->NotifyLanguageChanged(); + DoLanguageChange(); Dali::Application application(this); mLanguageChangedSignal.Emit( application ); } @@ -340,10 +370,16 @@ 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; } +std::string Application::GetResourcePath() +{ + return Internal::Adaptor::Framework::GetResourcePath(); +} + } // namespace Adaptor } // namespace Internal