Revert "Remove EGL surface in the update thread" 57/233957/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 20 May 2020 17:16:29 +0000 (17:16 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 20 May 2020 17:16:29 +0000 (17:16 +0000)
This reverts commit 5a03a49db1a8e90a7ee79cb225616f1d41747594.

Change-Id: Ie3453b21f519dfab7e4aec9e471e06eaa146ae8f

dali/integration-api/adaptor-framework/scene-holder-impl.cpp
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/adaptor/common/combined-update-render-controller.h
dali/internal/adaptor/common/thread-controller-interface.h
dali/internal/system/common/thread-controller.cpp
dali/internal/system/common/thread-controller.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-render-surface.cpp

index 7162a1c..2440b35 100644 (file)
@@ -133,8 +133,6 @@ SceneHolder::~SceneHolder()
     mAdaptor->RemoveObserver( *mLifeCycleObserver.get() );
     mAdaptor->RemoveWindow( this );
 
     mAdaptor->RemoveObserver( *mLifeCycleObserver.get() );
     mAdaptor->RemoveWindow( this );
 
-    mAdaptor->DeleteSurface( *mSurface.get() );
-
     mAdaptor = nullptr;
   }
 
     mAdaptor = nullptr;
   }
 
index 188c64e..2ecb543 100755 (executable)
@@ -557,16 +557,6 @@ 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();
 Dali::RenderSurfaceInterface& Adaptor::GetSurface() const
 {
   return *mWindows.front()->GetSurface();
@@ -1051,6 +1041,11 @@ bool Adaptor::IsMultipleWindowSupported() const
   return mConfigurationManager->IsMultipleWindowSupported();
 }
 
   return mConfigurationManager->IsMultipleWindowSupported();
 }
 
+bool Adaptor::IsRenderingWindows() const
+{
+  return ( mThreadController && mThreadController->IsRenderingWindows() );
+}
+
 void Adaptor::RequestUpdateOnce()
 {
   if( mThreadController )
 void Adaptor::RequestUpdateOnce()
 {
   if( mThreadController )
index d0d2379..c2a9ad4 100755 (executable)
@@ -292,12 +292,6 @@ public: // AdaptorInternalServices implementation
   bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
 
   /**
   bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
 
   /**
-   * @brief Deletes the rendering surface
-   * @param[in] surface to delete
-   */
-  void DeleteSurface( Dali::RenderSurfaceInterface& surface );
-
-  /**
    * @brief Retrieve the window that the given actor is added to.
    *
    * @param[in] actor The actor
    * @brief Retrieve the window that the given actor is added to.
    *
    * @param[in] actor The actor
@@ -449,6 +443,13 @@ public:
    */
   bool IsMultipleWindowSupported() const;
 
    */
   bool IsMultipleWindowSupported() const;
 
+  /**
+   * @brief Checks whether the windows are being rendered in the render thread.
+   *
+   * @return true if the windows are being rendered in the render thread, or false if not.
+   */
+  bool IsRenderingWindows() const;
+
 public:  //AdaptorInternalServices
 
   /**
 public:  //AdaptorInternalServices
 
   /**
index 7343b43..80bc0a3 100644 (file)
@@ -115,12 +115,12 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS
   mPendingRequestUpdate( FALSE ),
   mUseElapsedTimeAfterWait( FALSE ),
   mNewSurface( NULL ),
   mPendingRequestUpdate( FALSE ),
   mUseElapsedTimeAfterWait( FALSE ),
   mNewSurface( NULL ),
-  mDeletedSurface( nullptr ),
   mPostRendering( FALSE ),
   mSurfaceResized( FALSE ),
   mForceClear( FALSE ),
   mUploadWithoutRendering( FALSE ),
   mPostRendering( FALSE ),
   mSurfaceResized( FALSE ),
   mForceClear( FALSE ),
   mUploadWithoutRendering( FALSE ),
-  mFirstFrameAfterResume( FALSE )
+  mFirstFrameAfterResume( FALSE ),
+  mIsRenderingWindows( false )
 {
   LOG_EVENT_TRACE;
 
 {
   LOG_EVENT_TRACE;
 
@@ -324,29 +324,6 @@ void CombinedUpdateRenderController::ReplaceSurface( Dali::RenderSurfaceInterfac
   }
 }
 
   }
 }
 
-void CombinedUpdateRenderController::DeleteSurface( Dali::RenderSurfaceInterface* surface )
-{
-  LOG_EVENT_TRACE;
-
-  if( mUpdateRenderThread )
-  {
-    LOG_EVENT( "Starting to delete the surface, event-thread blocked" );
-
-    // Start replacing the surface.
-    {
-      ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
-      mPostRendering = FALSE; // Clear the post-rendering flag as Update/Render thread will delete the surface now
-      mDeletedSurface = surface;
-      mUpdateRenderThreadWaitCondition.Notify( lock );
-    }
-
-    // Wait until the surface has been deleted
-    sem_wait( &mEventThreadSemaphore );
-
-    LOG_EVENT( "Surface deleted, event-thread continuing" );
-  }
-}
-
 void CombinedUpdateRenderController::WaitForGraphicsInitialization()
 {
   LOG_EVENT_TRACE;
 void CombinedUpdateRenderController::WaitForGraphicsInitialization()
 {
   LOG_EVENT_TRACE;
@@ -686,6 +663,8 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
     AddPerformanceMarker( PerformanceInterface::RENDER_START );
 
 
     AddPerformanceMarker( PerformanceInterface::RENDER_START );
 
+    mIsRenderingWindows = true;
+
     // Upload shared resources
     mCore.PreRender( renderStatus, mForceClear, mUploadWithoutRendering );
 
     // Upload shared resources
     mCore.PreRender( renderStatus, mForceClear, mUploadWithoutRendering );
 
@@ -697,42 +676,33 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
       for( auto&& window : windows )
       {
 
       for( auto&& window : windows )
       {
-        Dali::Integration::Scene scene = window->GetScene();
-        Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
-
-        if ( scene && windowSurface )
+        if ( window && !window->IsBeingDeleted() )
         {
         {
-          windowSurface->InitializeGraphics();
+          Dali::Integration::Scene scene = window->GetScene();
+          Dali::RenderSurfaceInterface* windowSurface = window->GetSurface();
 
 
-          // Render off-screen frame buffers first if any
-          mCore.RenderScene( scene, true );
+          if ( scene && windowSurface )
+          {
+            windowSurface->InitializeGraphics();
 
 
-          // Switch to the EGL context of the surface
-          windowSurface->PreRender( surfaceResized ); // Switch GL context
+            // Render off-screen frame buffers first if any
+            mCore.RenderScene( scene, true );
 
 
-          // Render the surface
-          mCore.RenderScene( scene, false );
+            // Switch to the EGL context of the surface
+            windowSurface->PreRender( surfaceResized ); // Switch GL context
 
 
-          windowSurface->PostRender( false, false, surfaceResized ); // Swap Buffer
+            // Render the surface
+            mCore.RenderScene( scene, false );
+
+            windowSurface->PostRender( false, false, surfaceResized ); // Swap Buffer
+          }
         }
       }
     }
 
     mCore.PostRender( mUploadWithoutRendering );
 
         }
       }
     }
 
     mCore.PostRender( mUploadWithoutRendering );
 
-    //////////////////////////////
-    // DELETE SURFACE
-    //////////////////////////////
-
-    Dali::RenderSurfaceInterface* deletedSurface = ShouldSurfaceBeDeleted();
-    if( DALI_UNLIKELY( deletedSurface ) )
-    {
-      LOG_UPDATE_RENDER_TRACE_FMT( "Deleting Surface" );
-
-      deletedSurface->DestroySurface();
-
-      SurfaceDeleted();
-    }
+    mIsRenderingWindows = false;
 
     AddPerformanceMarker( PerformanceInterface::RENDER_END );
 
 
     AddPerformanceMarker( PerformanceInterface::RENDER_END );
 
@@ -818,14 +788,12 @@ bool CombinedUpdateRenderController::UpdateRenderReady( bool& useElapsedTime, bo
            ( mUpdateRenderThreadCanSleep && ! updateRequired && ! mPendingRequestUpdate ) ) && // Ensure we wait if we're supposed to be sleeping AND do not require another update
          ! mDestroyUpdateRenderThread && // Ensure we don't wait if the update-render-thread is supposed to be destroyed
          ! mNewSurface &&  // Ensure we don't wait if we need to replace the surface
            ( mUpdateRenderThreadCanSleep && ! updateRequired && ! mPendingRequestUpdate ) ) && // Ensure we wait if we're supposed to be sleeping AND do not require another update
          ! mDestroyUpdateRenderThread && // Ensure we don't wait if the update-render-thread is supposed to be destroyed
          ! mNewSurface &&  // Ensure we don't wait if we need to replace the surface
-         ! mDeletedSurface && // Ensure we don't wait if we need to delete the surface
          ! mSurfaceResized ) // Ensure we don't wait if we need to resize the surface
   {
     LOG_UPDATE_RENDER( "WAIT: mUpdateRenderRunCount:       %d", mUpdateRenderRunCount );
     LOG_UPDATE_RENDER( "      mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
     LOG_UPDATE_RENDER( "      mDestroyUpdateRenderThread:  %d", mDestroyUpdateRenderThread );
     LOG_UPDATE_RENDER( "      mNewSurface:                 %d", mNewSurface );
          ! mSurfaceResized ) // Ensure we don't wait if we need to resize the surface
   {
     LOG_UPDATE_RENDER( "WAIT: mUpdateRenderRunCount:       %d", mUpdateRenderRunCount );
     LOG_UPDATE_RENDER( "      mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
     LOG_UPDATE_RENDER( "      mDestroyUpdateRenderThread:  %d", mDestroyUpdateRenderThread );
     LOG_UPDATE_RENDER( "      mNewSurface:                 %d", mNewSurface );
-    LOG_UPDATE_RENDER( "      mDeletedSurface:             %d", mDeletedSurface );
     LOG_UPDATE_RENDER( "      mSurfaceResized:             %d", mSurfaceResized );
 
     // Reset the time when the thread is waiting, so the sleep-until time for
     LOG_UPDATE_RENDER( "      mSurfaceResized:             %d", mSurfaceResized );
 
     // Reset the time when the thread is waiting, so the sleep-until time for
@@ -845,7 +813,6 @@ bool CombinedUpdateRenderController::UpdateRenderReady( bool& useElapsedTime, bo
   LOG_COUNTER_UPDATE_RENDER( "mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
   LOG_COUNTER_UPDATE_RENDER( "mDestroyUpdateRenderThread:  %d", mDestroyUpdateRenderThread );
   LOG_COUNTER_UPDATE_RENDER( "mNewSurface:                 %d", mNewSurface );
   LOG_COUNTER_UPDATE_RENDER( "mUpdateRenderThreadCanSleep: %d, updateRequired: %d, mPendingRequestUpdate: %d", mUpdateRenderThreadCanSleep, updateRequired, mPendingRequestUpdate );
   LOG_COUNTER_UPDATE_RENDER( "mDestroyUpdateRenderThread:  %d", mDestroyUpdateRenderThread );
   LOG_COUNTER_UPDATE_RENDER( "mNewSurface:                 %d", mNewSurface );
-  LOG_COUNTER_UPDATE_RENDER( "mDeletedSurface:             %d", mDeletedSurface );
   LOG_COUNTER_UPDATE_RENDER( "mSurfaceResized:             %d", mSurfaceResized );
 
   mUseElapsedTimeAfterWait = FALSE;
   LOG_COUNTER_UPDATE_RENDER( "mSurfaceResized:             %d", mSurfaceResized );
 
   mUseElapsedTimeAfterWait = FALSE;
@@ -879,22 +846,6 @@ void CombinedUpdateRenderController::SurfaceReplaced()
   sem_post( &mEventThreadSemaphore );
 }
 
   sem_post( &mEventThreadSemaphore );
 }
 
-Dali::RenderSurfaceInterface* CombinedUpdateRenderController::ShouldSurfaceBeDeleted()
-{
-  ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
-
-  Dali::RenderSurfaceInterface* deletedSurface = mDeletedSurface;
-  mDeletedSurface = NULL;
-
-  return deletedSurface;
-}
-
-void CombinedUpdateRenderController::SurfaceDeleted()
-{
-  // Just increment the semaphore
-  sem_post( &mEventThreadSemaphore );
-}
-
 bool CombinedUpdateRenderController::ShouldSurfaceBeResized()
 {
   ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
 bool CombinedUpdateRenderController::ShouldSurfaceBeResized()
 {
   ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
@@ -956,7 +907,6 @@ void CombinedUpdateRenderController::PostRenderWaitForCompletion()
   ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
   while( mPostRendering &&
          ! mNewSurface &&                // We should NOT wait if we're replacing the surface
   ConditionalWait::ScopedLock lock( mUpdateRenderThreadWaitCondition );
   while( mPostRendering &&
          ! mNewSurface &&                // We should NOT wait if we're replacing the surface
-         ! mDeletedSurface &&            // We should NOT wait if we're deleting the surface
          ! mDestroyUpdateRenderThread )
   {
     mUpdateRenderThreadWaitCondition.Wait( lock );
          ! mDestroyUpdateRenderThread )
   {
     mUpdateRenderThreadWaitCondition.Wait( lock );
index 54cc67d..ca22517 100644 (file)
@@ -128,11 +128,6 @@ public:
   virtual void ReplaceSurface( Dali::RenderSurfaceInterface* surface );
 
   /**
   virtual void ReplaceSurface( Dali::RenderSurfaceInterface* surface );
 
   /**
-   * @copydoc ThreadControllerInterface::DeleteSurface()
-   */
-  virtual void DeleteSurface( Dali::RenderSurfaceInterface* surface );
-
-  /**
    * @copydoc ThreadControllerInterface::ResizeSurface()
    */
   virtual void ResizeSurface();
    * @copydoc ThreadControllerInterface::ResizeSurface()
    */
   virtual void ResizeSurface();
@@ -157,6 +152,11 @@ public:
    */
   virtual void AddSurface( Dali::RenderSurfaceInterface* surface );
 
    */
   virtual void AddSurface( Dali::RenderSurfaceInterface* surface );
 
+  /**
+   * @copydoc ThreadControllerInterface::IsRenderingWindows()
+   */
+  bool IsRenderingWindows() const override { return mIsRenderingWindows; }
+
 private:
 
   // Undefined copy constructor.
 private:
 
   // Undefined copy constructor.
@@ -250,21 +250,6 @@ private:
   void SurfaceReplaced();
 
   /**
   void SurfaceReplaced();
 
   /**
-   * Checks to see if the surface needs to be deleted.
-   * This will lock the mutex in mUpdateRenderThreadWaitCondition.
-   *
-   * @return Pointer to the deleted surface, nullptr otherwise
-   */
-  Dali::RenderSurfaceInterface* ShouldSurfaceBeDeleted();
-
-  /**
-   * Called by the Update/Render thread after a surface has been deleted.
-   *
-   * This will lock the mutex in mEventThreadWaitCondition
-   */
-  void SurfaceDeleted();
-
-  /**
    * Checks to see if the surface needs to be resized.
    * This will lock the mutex in mUpdateRenderThreadWaitCondition.
    *
    * Checks to see if the surface needs to be resized.
    * This will lock the mutex in mUpdateRenderThreadWaitCondition.
    *
@@ -380,7 +365,6 @@ private:
   volatile unsigned int             mUseElapsedTimeAfterWait;          ///< Whether we should use the elapsed time after waiting (set by the event-thread, read by the update-render-thread).
 
   Dali::RenderSurfaceInterface* volatile mNewSurface;                  ///< Will be set to the new-surface if requested (set by the event-thread, read & cleared by the update-render thread).
   volatile unsigned int             mUseElapsedTimeAfterWait;          ///< Whether we should use the elapsed time after waiting (set by the event-thread, read by the update-render-thread).
 
   Dali::RenderSurfaceInterface* volatile mNewSurface;                  ///< Will be set to the new-surface if requested (set by the event-thread, read & cleared by the update-render thread).
-  Dali::RenderSurfaceInterface* volatile mDeletedSurface;              ///< Will be set to the deleted surface if requested (set by the event-thread, read & cleared by the update-render thread).
 
   volatile unsigned int             mPostRendering;                    ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
   volatile unsigned int             mSurfaceResized;                   ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
 
   volatile unsigned int             mPostRendering;                    ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
   volatile unsigned int             mSurfaceResized;                   ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
@@ -389,6 +373,8 @@ private:
   volatile unsigned int             mUploadWithoutRendering;           ///< Will be set to upload the resource only (with no rendering)
 
   volatile unsigned int             mFirstFrameAfterResume;            ///< Will be set to check the first frame after resume (for log)
   volatile unsigned int             mUploadWithoutRendering;           ///< Will be set to upload the resource only (with no rendering)
 
   volatile unsigned int             mFirstFrameAfterResume;            ///< Will be set to check the first frame after resume (for log)
+
+  std::atomic<bool>                 mIsRenderingWindows;               ///< This is set only from the render thread and read only from the event thread
 };
 
 } // namespace Adaptor
 };
 
 } // namespace Adaptor
index 6b9055b..94276ff 100644 (file)
@@ -93,12 +93,6 @@ public:
   virtual void ReplaceSurface( Dali::RenderSurfaceInterface* surface ) = 0;
 
   /**
   virtual void ReplaceSurface( Dali::RenderSurfaceInterface* surface ) = 0;
 
   /**
-   * Deletes the surface.
-   * @param[in] surface The surface to be deleted
-   */
-  virtual void DeleteSurface( Dali::RenderSurfaceInterface* surface ) = 0;
-
-  /**
    * Resize the surface.
    */
   virtual void ResizeSurface() = 0;
    * Resize the surface.
    */
   virtual void ResizeSurface() = 0;
@@ -124,6 +118,11 @@ public:
    */
   virtual void AddSurface( Dali::RenderSurfaceInterface* surface ) = 0;
 
    */
   virtual void AddSurface( Dali::RenderSurfaceInterface* surface ) = 0;
 
+  /**
+   * @copydoc Dali::Adaptor::IsRenderingWindows()
+   */
+  virtual bool IsRenderingWindows() const = 0;
+
 protected:
 
   /**
 protected:
 
   /**
index a9054ec..605c76d 100644 (file)
@@ -90,11 +90,6 @@ void ThreadController::ReplaceSurface( Dali::RenderSurfaceInterface* newSurface
   mThreadControllerInterface->ReplaceSurface( newSurface );
 }
 
   mThreadControllerInterface->ReplaceSurface( newSurface );
 }
 
-void ThreadController::DeleteSurface( Dali::RenderSurfaceInterface* surface )
-{
-  mThreadControllerInterface->DeleteSurface( surface );
-}
-
 void ThreadController::ResizeSurface()
 {
   mThreadControllerInterface->ResizeSurface();
 void ThreadController::ResizeSurface()
 {
   mThreadControllerInterface->ResizeSurface();
@@ -120,6 +115,11 @@ void ThreadController::AddSurface( Dali::RenderSurfaceInterface* newSurface )
   mThreadControllerInterface->AddSurface( newSurface );
 }
 
   mThreadControllerInterface->AddSurface( newSurface );
 }
 
+bool ThreadController::IsRenderingWindows() const
+{
+  return mThreadControllerInterface->IsRenderingWindows();
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
 } // namespace Adaptor
 
 } // namespace Internal
index c4f3961..471a5f9 100644 (file)
@@ -112,12 +112,6 @@ public:
   void ReplaceSurface( Dali::RenderSurfaceInterface* surface );
 
   /**
   void ReplaceSurface( Dali::RenderSurfaceInterface* surface );
 
   /**
-   * Deletes the surface.
-   * @param surface The surface to be deleted
-   */
-  void DeleteSurface( Dali::RenderSurfaceInterface* surface );
-
-  /**
    * Resize the surface.
    */
   void ResizeSurface();
    * Resize the surface.
    */
   void ResizeSurface();
@@ -144,6 +138,11 @@ public:
    */
   void AddSurface( Dali::RenderSurfaceInterface* surface );
 
    */
   void AddSurface( Dali::RenderSurfaceInterface* surface );
 
+  /**
+   * @copydoc Dali::Adaptor::IsRenderingWindows()
+   */
+  bool IsRenderingWindows() const;
+
 private:
 
   // Undefined copy constructor.
 private:
 
   // Undefined copy constructor.
index 5321782..a0fd809 100644 (file)
@@ -99,6 +99,13 @@ Window::Window()
 
 Window::~Window()
 {
 
 Window::~Window()
 {
+  mIsBeingDeleted = true;
+
+  while ( mAdaptor && mAdaptor->IsRenderingWindows() )
+  {
+    std::this_thread::yield(); // to allow other threads to run
+  }
+
   if ( mEventHandler )
   {
     mEventHandler->RemoveObserver( *this );
   if ( mEventHandler )
   {
     mEventHandler->RemoveObserver( *this );
index c95d508..e1a344f 100644 (file)
@@ -85,6 +85,11 @@ WindowRenderSurface::~WindowRenderSurface()
   {
     delete mRotationTrigger;
   }
   {
     delete mRotationTrigger;
   }
+
+  if ( mEGLSurface )
+  {
+    DestroySurface();
+  }
 }
 
 void WindowRenderSurface::Initialize( Any surface )
 }
 
 void WindowRenderSurface::Initialize( Any surface )
@@ -259,13 +264,7 @@ void WindowRenderSurface::DestroySurface()
     DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: WinId (%d)\n", mWindowBase->GetNativeWindowId() );
 
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
     DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: WinId (%d)\n", mWindowBase->GetNativeWindowId() );
 
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-
     eglImpl.DestroySurface( mEGLSurface );
     eglImpl.DestroySurface( mEGLSurface );
-    mEGLSurface = nullptr;
-
-    // Destroy context also
-    eglImpl.DestroyContext( mEGLContext );
-    mEGLContext = nullptr;
 
     mWindowBase->DestroyEglWindow();
   }
 
     mWindowBase->DestroyEglWindow();
   }