Revert "Fix GlWindow when destroyed"
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Thu, 29 Oct 2020 10:15:41 +0000 (19:15 +0900)
committerDaekwang Ryu <dkdk.ryu@samsung.com>
Thu, 29 Oct 2020 10:15:41 +0000 (19:15 +0900)
This reverts commit b577ef4d0a47c1a1fcd9528f9dcb8b0757140fcc.

dali/internal/window-system/common/gl-window-impl.cpp
dali/internal/window-system/common/gl-window-impl.h

index f298d71..33952ea 100644 (file)
@@ -65,7 +65,8 @@ GlWindow* GlWindow::New( const PositionSize& positionSize, const std::string& na
 
 GlWindow::GlWindow()
 : mWindowBase(),
-  mGraphics( nullptr ),
+  mGraphics(),
+  mDisplayConnection( nullptr ),
   mEventHandler( nullptr ),
   mPositionSize(),
   mColorDepth( COLOR_DEPTH_24 ),
@@ -114,11 +115,6 @@ GlWindow::~GlWindow()
     mEventHandler->RemoveObserver( *this );
   }
 
-  if( Dali::Adaptor::IsAvailable() && mGLRenderCallback )
-  {
-    Dali::Adaptor::Get().RemoveIdle( mGLRenderCallback );
-  }
-
   if( mGLTerminateCallback )
   {
     mGLTerminateCallback();
@@ -126,7 +122,8 @@ GlWindow::~GlWindow()
 
   if( mIsEGLInitialize )
   {
-    EglGraphics *eglGraphics = static_cast<EglGraphics*>( mGraphics );
+    GraphicsInterface* graphics = mGraphics.get();
+    EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
     if( mEGLSurface )
@@ -140,6 +137,10 @@ GlWindow::~GlWindow()
       eglImpl.DestroyContext( mEGLContext );
       mEGLContext = nullptr;
     }
+
+    eglImpl.TerminateGles();
+
+    mGraphics->Destroy();
   }
 }
 
@@ -776,7 +777,8 @@ void GlWindow::RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFr
 
 bool GlWindow::RunCallback()
 {
-  EglGraphics *eglGraphics = static_cast<EglGraphics*>( mGraphics );
+  GraphicsInterface* graphics = mGraphics.get();
+  EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
   Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   eglImpl.MakeContextCurrent( mEGLSurface, mEGLContext );
@@ -825,10 +827,20 @@ void GlWindow::InitializeGraphics()
 {
   if( !mIsEGLInitialize )
   {
-    mGraphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
-    EglGraphics *eglGraphics = static_cast<EglGraphics *>(mGraphics);
-    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+    // Init Graphics
+    std::unique_ptr< GraphicsFactory > graphicsFactoryPtr = Utils::MakeUnique< GraphicsFactory >();
+    auto graphicsFactory = *graphicsFactoryPtr.get();
+
+    mGraphics = std::unique_ptr< GraphicsInterface >( &graphicsFactory.Create() );
+    GraphicsInterface* graphics = mGraphics.get();
+    EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
+    eglGraphics->Initialize( mDepth, mStencil, mMSAA );
+    eglGraphics->Create();
 
+    mDisplayConnection = std::unique_ptr< Dali::DisplayConnection >( Dali::DisplayConnection::New( *graphics, Dali::RenderSurfaceInterface::Type::WINDOW_RENDER_SURFACE ) );
+    mDisplayConnection->Initialize();
+
+    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
     if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_2_0 )
     {
       eglImpl.SetGlesVersion( 20 );
index 1bfc05a..fbecfc5 100644 (file)
@@ -363,7 +363,8 @@ public: // Signals
 private:
 
   std::unique_ptr< WindowBase >               mWindowBase;
-  GraphicsInterface*                          mGraphics;                    ///< Graphics interface
+  std::unique_ptr< GraphicsInterface >        mGraphics;                    ///< Graphics interface
+  std::unique_ptr< Dali::DisplayConnection >  mDisplayConnection;
   std::string                                 mName;
   std::string                                 mClassName;
   EventHandlerPtr                             mEventHandler;         ///< The window events handler