X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fadaptor-impl.cpp;h=868345d9d9e57da039c0b137f5503d148c0b0c20;hb=573600ba751204639c5ee68a528f2b72acf8385c;hp=dea6395ea283f8cfaf17ae03beaa2ffcfe0332a7;hpb=4c575a7e07b89da61dbdce3fdd5080b9d0ecbec7;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index dea6395..868345d 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -34,6 +34,8 @@ #include #include +#include + // INTERNAL INCLUDES #include #include @@ -65,9 +67,12 @@ #include #include +#include using Dali::TextAbstraction::FontClient; +extern std::string GetSystemCachePath(); + namespace Dali { @@ -155,7 +160,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: mCallbackManager = CallbackManager::New(); - SceneHolderPtr defaultWindow = mWindows.front(); + Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front(); DALI_ASSERT_DEBUG( defaultWindow->GetSurface() && "Surface not initialized" ); @@ -169,11 +174,13 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: GlImplementation& mGLES = eglGraphics->GetGlesInterface(); EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation(); + EglContextHelperImplementation& eglContextHelperImpl = eglGraphics->GetContextHelperImplementation(); mCore = Integration::Core::New( *this, *mPlatformAbstraction, mGLES, eglSyncImpl, + eglContextHelperImpl, dataRetentionPolicy , ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE, mGraphics->GetDepthBufferRequired(), @@ -181,7 +188,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: defaultWindow->SetAdaptor( Get() ); - Dali::Window window( dynamic_cast( ( &defaultWindow )->Get() ) ); + Dali::Window window( dynamic_cast( defaultWindow ) ); if ( window ) { mWindowCreatedSignal.Emit( window ); @@ -282,6 +289,40 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: { Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() ); } + + std::string systemCachePath = GetSystemCachePath(); + if ( systemCachePath.c_str() != NULL ) + { + Dali::FileStream fileStream( systemCachePath + "gpu-environment.conf", Dali::FileStream::READ | Dali::FileStream::TEXT ); + std::fstream& stream = dynamic_cast( fileStream.GetStream() ); + if( stream.is_open() ) + { + std::string line; + while( std::getline( stream, line ) ) + { + line.erase( line.find_last_not_of( " \t\r\n" ) + 1 ); + line.erase( 0, line.find_first_not_of( " \t\r\n" ) ); + if( '#' == *( line.cbegin() ) || line == "" ) + { + continue; + } + + std::istringstream stream( line ); + std::string environmentVariableName, environmentVariableValue; + std::getline(stream, environmentVariableName, ' '); + if( environmentVariableName == "DALI_ENV_MAX_TEXTURE_SIZE" && mEnvironmentOptions->GetMaxTextureSize() == 0 ) + { + std::getline(stream, environmentVariableValue); + setenv( environmentVariableName.c_str() , environmentVariableValue.c_str(), 1 ); + Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( std::atoi( environmentVariableValue.c_str() ) ); + } + } + } + else + { + DALI_LOG_ERROR( "Fail to open file : %s\n", ( systemCachePath + "gpu-environment.conf" ).c_str() ); + } + } } Adaptor::~Adaptor() @@ -337,7 +378,7 @@ void Adaptor::Start() // Start the callback manager mCallbackManager->Start(); - SceneHolderPtr defaultWindow = mWindows.front(); + Dali::Internal::Adaptor::SceneHolder* defaultWindow = mWindows.front(); unsigned int dpiHor, dpiVer; dpiHor = dpiVer = 0; @@ -348,12 +389,34 @@ void Adaptor::Start() FontClient fontClient = FontClient::Get(); fontClient.SetDpi( dpiHor, dpiVer ); - // Tell the core the size of the surface just before we start the render-thread - mCore->SurfaceResized( defaultWindow->GetSurface() ); - // Initialize the thread controller mThreadController->Initialize(); + if( !Dali::TizenPlatform::ImageLoader::MaxTextureSizeUpdated() ) + { + auto eglGraphics = static_cast( mGraphics ); + GlImplementation& mGLES = eglGraphics->GetGlesInterface(); + Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( mGLES.GetMaxTextureSize() ); + + std::string systemCachePath = GetSystemCachePath(); + if( systemCachePath.c_str() != NULL ) + { + const int dir_err = system( std::string( "mkdir " + systemCachePath ).c_str() ); + if (-1 == dir_err) + { + printf("Error creating directory!n"); + exit(1); + } + + Dali::FileStream fileStream( systemCachePath + "gpu-environment.conf", Dali::FileStream::WRITE | Dali::FileStream::TEXT ); + std::fstream& configFile = dynamic_cast( fileStream.GetStream() ); + if( configFile.is_open() ) + { + configFile << "DALI_ENV_MAX_TEXTURE_SIZE " << mGLES.GetMaxTextureSize() << std::endl; + } + } + } + ProcessCoreEvents(); // Ensure any startup messages are processed. // Initialize the image loader plugin @@ -378,7 +441,7 @@ void Adaptor::Pause() } // Pause all windows event handlers when adaptor paused - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { window->Pause(); } @@ -406,7 +469,7 @@ void Adaptor::Resume() mState = RUNNING; // Reset the event handlers when adaptor resumed - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { window->Resume(); } @@ -501,13 +564,10 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface ) { Internal::Adaptor::SceneHolder* windowImpl = &Dali::GetImplementation( window ); - for( SceneHolderPtr windowPtr : mWindows ) + for( auto windowPtr : mWindows ) { - if( windowPtr.Get() == windowImpl ) // the window is not deleted + if( windowPtr == windowImpl ) // the window is not deleted { - // Let the core know the surface size has changed - mCore->SurfaceResized( &newSurface ); - mResizedSignal.Emit( mAdaptor ); windowImpl->SetSurface( &newSurface ); @@ -523,6 +583,16 @@ void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::Rende } } +void Adaptor::DeleteSurface( Dali::RenderSurfaceInterface& surface ) +{ + // Flush the event queue to give the update-render thread chance + // to start processing messages for new camera setup etc as soon as possible + ProcessCoreEvents(); + + // This method blocks until the render thread has finished rendering the current surface. + mThreadController->DeleteSurface( &surface ); +} + Dali::RenderSurfaceInterface& Adaptor::GetSurface() const { return *mWindows.front()->GetSurface(); @@ -573,7 +643,7 @@ bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow, const std:: windowImpl.SetAdaptor( Get() ); // Add the new Window to the container - the order is not important - mWindows.push_back( SceneHolderPtr( &windowImpl ) ); + mWindows.push_back( &windowImpl ); Dali::Window window( dynamic_cast( &windowImpl ) ); if ( window ) @@ -729,6 +799,24 @@ Any Adaptor::GetNativeWindowHandle() return mWindows.front()->GetNativeHandle(); } +Any Adaptor::GetNativeWindowHandle( Dali::Actor actor ) +{ + Any nativeWindowHandle; + + Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor ); + + for( auto sceneHolder : mWindows ) + { + if ( scene == sceneHolder->GetScene() ) + { + nativeWindowHandle = sceneHolder->GetNativeHandle(); + break; + } + } + + return nativeWindowHandle; +} + Any Adaptor::GetGraphicsDisplay() { Any display; @@ -864,7 +952,7 @@ void Adaptor::OnWindowHidden() { bool allWindowsHidden = true; - for( SceneHolderPtr window : mWindows ) + for( auto window : mWindows ) { if ( window->IsVisible() ) { @@ -909,9 +997,6 @@ void Adaptor::OnDamaged( const DamageArea& area ) void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize ) { - // Let the core know the surface size has changed - mCore->SurfaceResized( surface ); - mResizedSignal.Emit( mAdaptor ); } @@ -1007,7 +1092,7 @@ Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor ) { if ( scene == window->GetScene() ) { - return window.Get(); + return window; } } @@ -1021,7 +1106,7 @@ Dali::WindowContainer Adaptor::GetWindows() const for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter ) { // Downcast to Dali::Window - Dali::Window window( dynamic_cast( iter->Get() ) ); + Dali::Window window( dynamic_cast( *iter ) ); if ( window ) { windows.push_back( window ); @@ -1061,7 +1146,7 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mUseRemoteSurface( false ) { DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" ); - mWindows.insert( mWindows.begin(), SceneHolderPtr( &Dali::GetImplementation( window ) ) ); + mWindows.insert( mWindows.begin(), &Dali::GetImplementation( window ) ); gThreadLocalAdaptor = this; }