[Tizen] Change GetTextureProperties
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / egl-graphics-controller.h
index 4999c9d..b89fa31 100644 (file)
@@ -35,6 +35,8 @@
 #include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-texture.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-types.h>
+#include <dali/internal/graphics/gles-impl/gles-sync-pool.h>
+#include <dali/internal/graphics/gles-impl/gles-texture-dependency-checker.h>
 #include <dali/internal/graphics/gles-impl/gles2-graphics-memory.h>
 
 namespace Dali
@@ -51,6 +53,8 @@ namespace GLES
 {
 class CommandBuffer;
 class PipelineCache;
+class SyncPool;
+class TextureDependencyChecker;
 } // namespace GLES
 
 /**
@@ -62,9 +66,9 @@ class EglGraphicsController : public Graphics::Controller
 {
 public:
   /**
-   * @brief Deault constructor
+   * @brief Constructor
    */
-  EglGraphicsController() = default;
+  EglGraphicsController();
 
   /**
    * @brief Destructor
@@ -126,26 +130,10 @@ public:
   void Shutdown() override
   {
     mIsShuttingDown = true;
-  }
 
-  /**
-   * @copydoc Dali::Graphics::Destroy()
-   */
-  void Destroy() override
-  {
     // 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();
@@ -161,6 +149,13 @@ public:
   }
 
   /**
+   * @copydoc Dali::Graphics::Destroy()
+   */
+  void Destroy() override
+  {
+  }
+
+  /**
    * @copydoc Dali::Graphics::UpdateTextures()
    */
   void UpdateTextures(const std::vector<TextureUpdateInfo>&       updateInfoList,
@@ -303,17 +298,11 @@ public:
   /**
    * @copydoc Dali::Graphics::GetTextureProperties()
    */
-  const TextureProperties& GetTextureProperties(const Texture& texture) override
-  {
-    // for compiler not to moan
-    static TextureProperties dummy{};
-    return dummy;
-  }
+  TextureProperties GetTextureProperties(const Texture& texture) override;
 
   /**
    * @copydoc Dali::Graphics::Controller::GetPipelineReflection()
    */
-
   [[nodiscard]] const Reflection& GetProgramReflection(const Graphics::Program& program) override;
 
   /**
@@ -474,26 +463,6 @@ 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,
@@ -501,29 +470,26 @@ public:
    */
   void Flush()
   {
-    if(DALI_LIKELY(!mIsShuttingDown))
+    if(!mCreateTextureQueue.empty() ||
+       !mCreateBufferQueue.empty() ||
+       !mCreateFramebufferQueue.empty() ||
+       !mTextureUpdateRequests.empty() ||
+       !mTextureMipmapGenerationRequests.empty())
     {
-      if(!mCreateTextureQueue.empty() ||
-         !mCreateBufferQueue.empty() ||
-         !mCreateFramebufferQueue.empty() ||
-         !mTextureUpdateRequests.empty() ||
-         !mTextureMipmapGenerationRequests.empty())
-      {
-        mGraphics->ActivateResourceContext();
-      }
+      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();
@@ -754,6 +720,11 @@ public:
   void ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget);
 
   /**
+   * Invoked after all rendering has finished. Used to clean up sync resources
+   */
+  void PostRender();
+
+  /**
    * Creates a GLES context for the given render surface
    *
    * @param[in] surface The surface whose GLES context to be created.
@@ -799,6 +770,11 @@ public:
     return mSharedContext;
   }
 
+  GLES::SyncPool& GetSyncPool()
+  {
+    return mSyncPool;
+  }
+
 private:
   Integration::GlAbstraction*              mGlAbstraction{nullptr};
   Integration::GlContextHelperAbstraction* mGlContextHelperAbstraction{nullptr};
@@ -844,6 +820,9 @@ private:
   std::queue<const GLES::CommandBuffer*> mPresentationCommandBuffers{}; ///< Queue of reusable command buffers used by presentation engine
 
   void* mSharedContext{nullptr}; ///< Shared EGL context
+
+  GLES::TextureDependencyChecker mTextureDependencyChecker; // Checks if FBO textures need syncing
+  GLES::SyncPool                 mSyncPool;
 };
 
 } // namespace Graphics