Revert "[Tizen] To get MaxTextureSize by using glGetIntegerv not by using environment...
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
index dea6395..6256e04 100755 (executable)
@@ -155,7 +155,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 +169,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 +183,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
 
   defaultWindow->SetAdaptor( Get() );
 
-  Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( ( &defaultWindow )->Get() ) );
+  Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( defaultWindow ) );
   if ( window )
   {
     mWindowCreatedSignal.Emit( window );
@@ -337,7 +339,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,9 +350,6 @@ 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();
 
@@ -378,7 +377,7 @@ void Adaptor::Pause()
     }
 
     // Pause all windows event handlers when adaptor paused
-    for( SceneHolderPtr window : mWindows )
+    for( auto window : mWindows )
     {
       window->Pause();
     }
@@ -406,7 +405,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 +500,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 +519,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 +579,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<Dali::Internal::Adaptor::Window*>( &windowImpl ) );
   if ( window )
@@ -864,7 +870,7 @@ void Adaptor::OnWindowHidden()
   {
     bool allWindowsHidden = true;
 
-    for( SceneHolderPtr window : mWindows )
+    for( auto window : mWindows )
     {
       if ( window->IsVisible() )
       {
@@ -909,9 +915,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 +1010,7 @@ Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor )
   {
     if ( scene == window->GetScene() )
     {
-      return window.Get();
+      return window;
     }
   }
 
@@ -1021,7 +1024,7 @@ Dali::WindowContainer Adaptor::GetWindows() const
   for ( auto iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
     // Downcast to Dali::Window
-    Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( iter->Get() ) );
+    Dali::Window window( dynamic_cast<Dali::Internal::Adaptor::Window*>( *iter ) );
     if ( window )
     {
       windows.push_back( window );
@@ -1061,7 +1064,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;
 }