Fix GlWindow when destroyed 84/246384/2
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Wed, 28 Oct 2020 06:27:59 +0000 (15:27 +0900)
committerDaekwang Ryu <dkdk.ryu@samsung.com>
Thu, 29 Oct 2020 09:50:28 +0000 (18:50 +0900)
GlWindow created a EglGraphics.
When GlWindow was destroyed, the EglGraphics called eglTerminate().
It caused destroying all egl resources.
GlWindow uses EglGraphics of Adaptor.

Change-Id: I78e0ea977d4d795e3dbb001e4214802d32282808

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

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