/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
#include <dali/internal/adaptor/common/application-impl.h>
// EXTERNAL INCLUDES
+#include <dali/public-api/object/object-registry.h>
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/common/singleton-service.h>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/style-monitor.h>
#include <dali/devel-api/text-abstraction/font-client.h>
+#include <dali/devel-api/adaptor-framework/accessibility-impl.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>
namespace Adaptor
{
-namespace
-{
-
-const float DEFAULT_STEREO_BASE( 65.0f );
-
-} // unnamed namespace
-
ApplicationPtr Application::gPreInitializedApplication( NULL );
ApplicationPtr Application::New(
{
if( !gPreInitializedApplication )
{
- gPreInitializedApplication = new Application ( argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL );
+ Dali::TextAbstraction::FontClientPreInitialize();
+ gPreInitializedApplication = new Application ( argc, argv, "", Dali::Application::OPAQUE, PositionSize(), Framework::NORMAL );
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 );
}
}
mPauseSignal(),
mResumeSignal(),
mResetSignal(),
- mResizeSignal(),
mAppControlSignal(),
mLanguageChangedSignal(),
mRegionChangedSignal(),
- mBatteryLowSignal(),
- mMemoryLowSignal(),
mEventLoop( nullptr ),
mFramework( nullptr ),
- mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ),
mCommandLineOptions( nullptr ),
- mSingletonService( SingletonService::New() ),
mAdaptorBuilder( nullptr ),
mAdaptor( nullptr ),
mMainWindow(),
mMainWindowMode( windowMode ),
mMainWindowName(),
- mMainWindowReplaced( false ),
mStylesheet( stylesheet ),
mEnvironmentOptions(),
mWindowPositionSize( positionSize ),
mLaunchpadState( Launchpad::NONE ),
- mSlotDelegate( this ),
- mViewMode( MONO ),
- mStereoBase( DEFAULT_STEREO_BASE )
+ mSlotDelegate( this )
{
// Get mName from environment options
mMainWindowName = mEnvironmentOptions.GetWindowName();
Application::~Application()
{
- mSingletonService.UnregisterAll();
+ SingletonService service = SingletonService::Get();
+ // Note this can be false i.e. if Application has never created a Core instance
+ if( service )
+ {
+ service.UnregisterAll();
+ }
mMainWindow.Reset();
delete mAdaptor;
const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName();
- Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT );
+ 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
Integration::SceneHolder sceneHolder = Integration::SceneHolder( &Dali::GetImplementation( mMainWindow ) );
- mAdaptor = Adaptor::New( graphicsFactory, sceneHolder, mContextLossConfiguration, &mEnvironmentOptions );
-
- mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
+ mAdaptor = Adaptor::New( graphicsFactory, sceneHolder, &mEnvironmentOptions );
Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
}
mAdaptorBuilder = new AdaptorBuilder();
}
-void Application::MainLoop(Dali::Configuration::ContextLoss configuration)
+void Application::MainLoop()
{
- mContextLossConfiguration = configuration;
-
// Run the application
mFramework->Run();
}
void Application::QuitFromMainLoop()
{
+ Accessibility::Bridge::GetCurrentBridge()->Terminate();
+
mAdaptor->Stop();
mFramework->Quit();
mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) );
CreateAdaptorBuilder();
-
// If an application was pre-initialized, a window was made in advance
if( mLaunchpadState == Launchpad::NONE )
{
// Run the adaptor
mAdaptor->Start();
-
- // Check if user requires no vsyncing and set Adaptor
- if (mCommandLineOptions->noVSyncOnRender)
- {
- mAdaptor->SetUseHardwareVSync(false);
- }
+ Accessibility::Accessible::SetObjectRegistry(mAdaptor->GetObjectRegistry());
if( ! mStylesheet.empty() )
{
PauseSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnPause );
ResumeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResume );
ResetSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnReset );
- ResizeSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnResize );
LanguageChangedSignal().Connect( &GetImplementation( lifecycleController ), &LifecycleController::OnLanguageChanged );
Dali::Application application(this);
void Application::OnBatteryLow( Dali::DeviceStatus::Battery::Status status )
{
Dali::Application application(this);
- mBatteryLowSignal.Emit( application );
-
mLowBatterySignal.Emit( status );
}
void Application::OnMemoryLow( Dali::DeviceStatus::Memory::Status status )
{
Dali::Application application(this);
- mMemoryLowSignal.Emit( application );
-
mLowMemorySignal.Emit( status );
}
-void Application::OnResize(Dali::Adaptor& adaptor)
+void Application::OnSurfaceCreated( Any newSurface )
+{
+ void* newWindow = AnyCast< void* >( newSurface );
+ void* oldWindow = AnyCast< void* >( mMainWindow.GetNativeHandle() );
+ if( oldWindow != newWindow )
+ {
+ auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
+ std::unique_ptr< WindowRenderSurface > newSurfacePtr
+ = renderSurfaceFactory->CreateWindowRenderSurface( PositionSize(), newSurface, true );
+
+ mAdaptor->ReplaceSurface( mMainWindow, *newSurfacePtr.release() );
+ }
+}
+
+void Application::OnSurfaceDestroyed( Any surface )
{
- Dali::Application application(this);
- mResizeSignal.Emit( application );
}
bool Application::AddIdle( CallbackBase* callback, bool hasReturnValue )
return mFramework->GetLanguage();
}
-Dali::Adaptor& Application::GetAdaptor()
+Dali::ObjectRegistry Application::GetObjectRegistry() const
{
- return *mAdaptor;
-}
-
-Dali::Window Application::GetWindow()
-{
- // 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
+ Dali::ObjectRegistry objectRegistry;
+ if( mAdaptor )
{
- return mMainWindow;
+ objectRegistry = mAdaptor->GetObjectRegistry();
}
+ return objectRegistry;
}
-// Stereoscopy
-
-void Application::SetViewMode( ViewMode viewMode )
-{
- mViewMode = viewMode;
-}
-
-ViewMode Application::GetViewMode() const
-{
- return mViewMode;
-}
-
-void Application::SetStereoBase( float stereoBase )
-{
- mStereoBase = stereoBase;
-}
-
-float Application::GetStereoBase() const
+Dali::Adaptor& Application::GetAdaptor()
{
- return mStereoBase;
+ return *mAdaptor;
}
-void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name )
+Dali::Window Application::GetWindow()
{
- // This API is kept just for backward compatibility to make the test case pass.
-
- mMainWindowReplaced = true;
- OnResize( *mAdaptor );
+ return mMainWindow;
}
std::string Application::GetResourcePath()
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;