[3.0] Remove Adaptor::Pause()/Resume() from application::OnPause()/OnResume()
[platform/core/uifw/dali-adaptor.git] / adaptors / common / application-impl.cpp
index 87daa3c..bd885e6 100644 (file)
@@ -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(),
@@ -91,8 +93,8 @@ 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()
@@ -102,6 +104,7 @@ Application::~Application()
   delete mFramework;
   delete mCommandLineOptions;
   delete mAdaptor;
+
   mWindow.Reset();
 }
 
@@ -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)
@@ -169,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
@@ -232,7 +237,9 @@ void Application::OnTerminate()
 
 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 );
 }
@@ -243,7 +250,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()
@@ -340,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;
 }