X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fapplication-impl.cpp;h=17d0282fa1bc5f272cf1e153443330b51e3f18ce;hb=6e77f2f2c059b23e19ee8387397192431a88232a;hp=ce49e607e2b6d1b4551e157adfad257aa15b2b64;hpb=5285ea200c4b02668d42366649988fb2965e81c9;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index ce49e60..17d0282 100755 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -20,13 +20,14 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include #include +#include #include #include -#include #include #include #include @@ -80,15 +81,8 @@ void Application::PreInitialize( int* argc, char** argv[] ) 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 ); } } @@ -109,7 +103,6 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee mFramework( nullptr ), mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ), mCommandLineOptions( nullptr ), - mSingletonService( SingletonService::New() ), mAdaptorBuilder( nullptr ), mAdaptor( nullptr ), mMainWindow(), @@ -139,7 +132,12 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee 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; @@ -168,7 +166,7 @@ void Application::CreateWindow() 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 @@ -181,11 +179,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() @@ -227,7 +227,6 @@ void Application::OnInit() mFramework->AddAbortCallback( MakeCallback( this, &Application::QuitFromMainLoop ) ); CreateAdaptorBuilder(); - // If an application was pre-initialized, a window was made in advance if( mLaunchpadState == Launchpad::NONE ) { @@ -239,12 +238,6 @@ void Application::OnInit() // 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 ); @@ -353,6 +346,24 @@ void Application::OnMemoryLow( Dali::DeviceStatus::Memory::Status status ) 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 Application::OnResize(Dali::Adaptor& adaptor) { Dali::Application application(this); @@ -385,7 +396,7 @@ Dali::Window Application::GetWindow() // just for backward compatibility to make the test case pass if ( mMainWindowReplaced ) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( PositionSize(), "ReplacedWindow", "", false ); + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(PositionSize(), "ReplacedWindow", "", false); return Dali::Window( window ); } else @@ -439,6 +450,15 @@ 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;