// EXTERNAL INCLUDES
#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/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>
if( !gPreInitializedApplication )
{
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 );
}
}
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 ),
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();
- mMainWindow = Dali::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
GetImplementation( mMainWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit );
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()
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);
- }
-
if( ! mStylesheet.empty() )
{
Dali::StyleMonitor::Get().SetTheme( mStylesheet );
mLowMemorySignal.Emit( status );
}
+
+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 )
+{
+ void* windowToDelete = AnyCast< void* >( surface );
+ void* oldWindow = AnyCast< void* >( mMainWindow.GetNativeHandle() );
+ if( oldWindow == windowToDelete )
+ {
+ mAdaptor->DeleteSurface( mAdaptor->GetSurface() );
+ }
+}
+
void Application::OnResize(Dali::Adaptor& adaptor)
{
Dali::Application application(this);
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;
+ }
}
// Stereoscopy
void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name )
{
- Any surface;
- auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
- std::unique_ptr<Internal::Adaptor::WindowRenderSurface> renderSurface =
- renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, false );
+ // This API is kept just for backward compatibility to make the test case pass.
- Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface( mMainWindow, *renderSurface.release() );
- mWindowPositionSize = positionSize;
+ mMainWindowReplaced = true;
+ OnResize( *mAdaptor );
}
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;