Prevent texture removal after TextureManager destroyed
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / texture-manager-impl.h
index 5b6a98e..8685ec6 100644 (file)
@@ -136,6 +136,18 @@ public:
   };
   using MaskingDataPointer = std::unique_ptr<MaskingData>;
 
+
+  /**
+   * Class to provide lifecycle event on destruction of texture manager.
+   */
+  struct LifecycleObserver
+  {
+    /**
+     * Called shortly before the texture manager is destroyed.
+     */
+    virtual void TextureManagerDestroyed() = 0;
+  };
+
   /**
    * Constructor.
    */
@@ -144,8 +156,7 @@ public:
   /**
    * Destructor.
    */
-  ~TextureManager() = default;
-
+  ~TextureManager();
 
   // TextureManager Main API:
 
@@ -329,6 +340,19 @@ public:
    */
   TextureSet RemoveExternalTexture( const std::string& url );
 
+  /**
+   * Add an observer to the object.
+   * @param[in] observer The observer to add.
+   */
+  void AddObserver( TextureManager::LifecycleObserver& observer );
+
+  /**
+   * Remove an observer from the object
+   * @pre The observer has already been added.
+   * @param[in] observer The observer to remove.
+   */
+  void RemoveObserver( TextureManager::LifecycleObserver& observer );
+
 private:
 
   /**
@@ -710,6 +734,7 @@ private:  // Member Variables:
   RoundRobinContainerView< AsyncLoadingHelper > mAsyncLocalLoaders;    ///< The Asynchronous image loaders used to provide all local async loads
   RoundRobinContainerView< AsyncLoadingHelper > mAsyncRemoteLoaders;   ///< The Asynchronous image loaders used to provide all remote async loads
   std::vector< ExternalTextureInfo >            mExternalTextures;     ///< Externally provided textures
+  Dali::Vector<LifecycleObserver*>              mLifecycleObservers;   ///< Lifecycle observers of texture manager
   TextureId                                     mCurrentTextureId;     ///< The current value used for the unique Texture Id generation
 };