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