[Tizen] Do not call gl functions during shutdown
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Tue, 26 Apr 2022 01:47:18 +0000 (10:47 +0900)
committerDaekwang Ryu <dkdk.ryu@samsung.com>
Tue, 26 Apr 2022 01:47:41 +0000 (10:47 +0900)
This reverts commit cab49c57d6d2eff1b6a501661f0bfa088068c4fa.

Change-Id: I8992ad392c54ec348362af1d3bf3035090f4ea18

dali/internal/graphics/gles-impl/egl-graphics-controller.h

index 6af7383..ec6c894 100644 (file)
@@ -136,6 +136,16 @@ public:
     // Final flush
     Flush();
 
+    ClearTextureUpdateQueue();
+
+    // Remove all create queue and command queue.
+    // Note that all memory are already deallocated at Final flush.
+    mCreateTextureQueue              = {};
+    mCreateBufferQueue               = {};
+    mCreateFramebufferQueue          = {};
+    mTextureMipmapGenerationRequests = {};
+    mCommandQueue                    = {};
+
     if(mContext)
     {
       mContext->GlContextDestroyed();
@@ -464,6 +474,26 @@ public:
   }
 
   /**
+   * @brief Clears the texture update queue
+   */
+  void ClearTextureUpdateQueue()
+  {
+    // Remove remained CPU-allocated texture memory
+    while(!mTextureUpdateRequests.empty())
+    {
+      auto& request = mTextureUpdateRequests.front();
+      auto& source  = request.second;
+
+      if(source.sourceType == Graphics::TextureUpdateSourceInfo::Type::MEMORY)
+      {
+        // free staging memory
+        free(source.memorySource.memory);
+      }
+      mTextureUpdateRequests.pop();
+    }
+  }
+
+  /**
    * @brief Flushes all pending updates
    *
    * Function flushes all pending resource constructions,
@@ -471,26 +501,29 @@ public:
    */
   void Flush()
   {
-    if(!mCreateTextureQueue.empty() ||
-       !mCreateBufferQueue.empty() ||
-       !mCreateFramebufferQueue.empty() ||
-       !mTextureUpdateRequests.empty() ||
-       !mTextureMipmapGenerationRequests.empty())
+    if(DALI_LIKELY(!mIsShuttingDown))
     {
-      mGraphics->ActivateResourceContext();
-    }
+      if(!mCreateTextureQueue.empty() ||
+         !mCreateBufferQueue.empty() ||
+         !mCreateFramebufferQueue.empty() ||
+         !mTextureUpdateRequests.empty() ||
+         !mTextureMipmapGenerationRequests.empty())
+      {
+        mGraphics->ActivateResourceContext();
+      }
 
-    // Process creations
-    ProcessCreateQueues();
+      // Process creations
+      ProcessCreateQueues();
 
-    // Process updates
-    ProcessTextureUpdateQueue();
+      // Process updates
+      ProcessTextureUpdateQueue();
 
-    // Process texture mipmap generation requests
-    ProcessTextureMipmapGenerationQueue();
+      // Process texture mipmap generation requests
+      ProcessTextureMipmapGenerationQueue();
 
-    // Process main command queue
-    ProcessCommandQueues();
+      // Process main command queue
+      ProcessCommandQueues();
+    }
 
     // Reset texture cache in the contexts while destroying textures
     ResetTextureCache();