From 79b4bb7ff3ef27652fa3caa1ba5264b78ad918d8 Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Thu, 29 Oct 2020 19:15:41 +0900 Subject: [PATCH] Revert "Fix GlWindow when destroyed" This reverts commit b577ef4d0a47c1a1fcd9528f9dcb8b0757140fcc. --- .../window-system/common/gl-window-impl.cpp | 34 +++++++++++++++------- .../internal/window-system/common/gl-window-impl.h | 3 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/dali/internal/window-system/common/gl-window-impl.cpp b/dali/internal/window-system/common/gl-window-impl.cpp index f298d71..33952ea 100644 --- a/dali/internal/window-system/common/gl-window-impl.cpp +++ b/dali/internal/window-system/common/gl-window-impl.cpp @@ -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( mGraphics ); + GraphicsInterface* graphics = mGraphics.get(); + EglGraphics *eglGraphics = static_cast( 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( mGraphics ); + GraphicsInterface* graphics = mGraphics.get(); + EglGraphics *eglGraphics = static_cast( 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(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( 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 ); diff --git a/dali/internal/window-system/common/gl-window-impl.h b/dali/internal/window-system/common/gl-window-impl.h index 1bfc05a..fbecfc5 100644 --- a/dali/internal/window-system/common/gl-window-impl.h +++ b/dali/internal/window-system/common/gl-window-impl.h @@ -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 -- 2.7.4