[Tizen](ATSPI) squashed implementation
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / application-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index fe29875..40b16d9
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/accessibility.h>
 #include <dali/devel-api/adaptor-framework/style-monitor.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/system/common/command-line-options.h>
 #include <dali/internal/adaptor/common/framework.h>
 #include <dali/internal/system/common/singleton-service-impl.h>
 #include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
+#include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-render-surface.h>
+#include <dali/internal/window-system/common/render-surface-factory.h>
+
+// To disable a macro with the same name from one of OpenGL headers
+#undef Status
 
 namespace Dali
 {
@@ -48,6 +56,13 @@ namespace Internal
 namespace Adaptor
 {
 
+namespace
+{
+
+const float DEFAULT_STEREO_BASE( 65.0f );
+
+} // unnamed namespace
+
 ApplicationPtr Application::gPreInitializedApplication( NULL );
 
 ApplicationPtr Application::New(
@@ -71,6 +86,11 @@ void Application::PreInitialize( int* argc, char** argv[] )
     gPreInitializedApplication->CreateWindow();    // Only create window
 
     gPreInitializedApplication->mLaunchpadState = Launchpad::PRE_INITIALIZED;
+
+    //Make DefaultFontDescription cached
+    Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
+    Dali::TextAbstraction::FontDescription defaultFontDescription;
+    fontClient.GetDefaultPlatformFontDescription( defaultFontDescription );
   }
 }
 
@@ -97,11 +117,14 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee
   mMainWindow(),
   mMainWindowMode( windowMode ),
   mMainWindowName(),
+  mMainWindowReplaced( false ),
   mStylesheet( stylesheet ),
   mEnvironmentOptions(),
   mWindowPositionSize( positionSize ),
   mLaunchpadState( Launchpad::NONE ),
-  mSlotDelegate( this )
+  mSlotDelegate( this ),
+  mViewMode( MONO ),
+  mStereoBase( DEFAULT_STEREO_BASE )
 {
   // Get mName from environment options
   mMainWindowName = mEnvironmentOptions.GetWindowName();
@@ -146,13 +169,9 @@ void Application::CreateWindow()
   }
 
   const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName();
-  mMainWindow = Dali::Window::New( mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT );
 
-  int indicatorVisibleMode = mEnvironmentOptions.GetIndicatorVisibleMode();
-  if( indicatorVisibleMode >= Dali::Window::INVISIBLE && indicatorVisibleMode <= Dali::Window::AUTO )
-  {
-    GetImplementation( mMainWindow ).SetIndicatorVisibleMode( static_cast< Dali::Window::IndicatorVisibleMode >( indicatorVisibleMode ) );
-  }
+  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT );
+  mMainWindow = Dali::Window( window );
 
   // Quit the application when the window is closed
   GetImplementation( mMainWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit );
@@ -164,11 +183,13 @@ void Application::CreateAdaptor()
 
   auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
 
-  mAdaptor = Dali::Internal::Adaptor::Adaptor::New( graphicsFactory, mMainWindow, mContextLossConfiguration, &mEnvironmentOptions );
+  Integration::SceneHolder sceneHolder = Integration::SceneHolder( &Dali::GetImplementation( mMainWindow ) );
+
+  mAdaptor = Adaptor::New( graphicsFactory, sceneHolder, mContextLossConfiguration, &mEnvironmentOptions );
 
   mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
 
-  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
+  Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
 }
 
 void Application::CreateAdaptorBuilder()
@@ -199,14 +220,18 @@ void Application::Quit()
 
 void Application::QuitFromMainLoop()
 {
+  Accessibility::Bridge::GetCurrentBridge()->Terminate();
+
   mAdaptor->Stop();
 
   mFramework->Quit();
   // This will trigger OnTerminate(), below, after the main loop has completed.
 }
 
-void Application::DoInit()
+void Application::OnInit()
 {
+  mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) );
+
   CreateAdaptorBuilder();
 
   // If an application was pre-initialized, a window was made in advance
@@ -220,54 +245,10 @@ void Application::DoInit()
   // Run the adaptor
   mAdaptor->Start();
 
-  // Check if user requires no vsyncing and set Adaptor
-  if (mCommandLineOptions->noVSyncOnRender)
-  {
-    mAdaptor->SetUseHardwareVSync(false);
-  }
-
   if( ! mStylesheet.empty() )
   {
     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();
-  }
-
-  mMainWindow.Reset(); // This only resets (clears) the default Window
-}
-
-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();
@@ -283,7 +264,7 @@ void Application::OnInit()
   Dali::Application application(this);
   mInitSignal.Emit( application );
 
-  DoStart();
+  mAdaptor->NotifySceneCreated();
 }
 
 void Application::OnTerminate()
@@ -294,7 +275,13 @@ void Application::OnTerminate()
   Dali::Application application(this);
   mTerminateSignal.Emit( application );
 
-  DoTerminate();
+  if( mAdaptor )
+  {
+    // Ensure that the render-thread is not using the surface(window) after we delete it
+    mAdaptor->Stop();
+  }
+
+  mMainWindow.Reset(); // This only resets (clears) the default Window
 }
 
 void Application::OnPause()
@@ -339,7 +326,7 @@ void Application::OnAppControl(void *data)
 
 void Application::OnLanguageChanged()
 {
-  DoLanguageChange();
+  mAdaptor->NotifyLanguageChanged();
   Dali::Application application(this);
   mLanguageChangedSignal.Emit( application );
 }
@@ -365,6 +352,7 @@ void Application::OnMemoryLow( Dali::DeviceStatus::Memory::Status status )
 
   mLowMemorySignal.Emit( status );
 }
+
 void Application::OnResize(Dali::Adaptor& adaptor)
 {
   Dali::Application application(this);
@@ -393,27 +381,47 @@ Dali::Adaptor& Application::GetAdaptor()
 
 Dali::Window Application::GetWindow()
 {
-  return mMainWindow;
+  // Changed to return a different window handle after ReplaceWindow is called
+  // just for backward compatibility to make the test case pass
+  if ( mMainWindowReplaced )
+  {
+    Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( PositionSize(), "ReplacedWindow", "", false );
+    return Dali::Window( window );
+  }
+  else
+  {
+    return mMainWindow;
+  }
 }
 
-void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name )
+// Stereoscopy
+
+void Application::SetViewMode( ViewMode viewMode )
+{
+  mViewMode = viewMode;
+}
+
+ViewMode Application::GetViewMode() const
 {
-  Dali::Window newWindow = Dali::Window::New( positionSize, name, mMainWindowMode == Dali::Application::TRANSPARENT );
-  Window& windowImpl = GetImplementation(newWindow);
-  windowImpl.SetAdaptor(*mAdaptor);
+  return mViewMode;
+}
 
-  int indicatorVisibleMode = mEnvironmentOptions.GetIndicatorVisibleMode();
-  if( indicatorVisibleMode >= Dali::Window::INVISIBLE && indicatorVisibleMode <= Dali::Window::AUTO )
-  {
-    GetImplementation( newWindow ).SetIndicatorVisibleMode( static_cast< Dali::Window::IndicatorVisibleMode >( indicatorVisibleMode ) );
-  }
+void Application::SetStereoBase( float stereoBase )
+{
+  mStereoBase = stereoBase;
+}
 
-  Dali::RenderSurface* renderSurface = windowImpl.GetSurface();
+float Application::GetStereoBase() const
+{
+  return mStereoBase;
+}
 
-  Any nativeWindow = newWindow.GetNativeHandle();
-  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface);
-  mMainWindow = newWindow;
-  mWindowPositionSize = positionSize;
+void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name )
+{
+  // This API is kept just for backward compatibility to make the test case pass.
+
+  mMainWindowReplaced = true;
+  OnResize( *mAdaptor );
 }
 
 std::string Application::GetResourcePath()
@@ -421,11 +429,25 @@ std::string Application::GetResourcePath()
   return Internal::Adaptor::Framework::GetResourcePath();
 }
 
+std::string Application::GetDataPath()
+{
+  return Internal::Adaptor::Framework::GetDataPath();
+}
+
 void Application::SetStyleSheet( const std::string& stylesheet )
 {
   mStylesheet = stylesheet;
 }
 
+void Application::SetCommandLineOptions( int* argc, char **argv[] )
+{
+  delete mCommandLineOptions;
+
+  mCommandLineOptions = new CommandLineOptions( argc, argv );
+
+  mFramework->SetCommandLineOptions( argc, argv );
+}
+
 ApplicationPtr Application::GetPreInitializedApplication()
 {
   return gPreInitializedApplication;