Modify codes for Dali Windows backend
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / texture-manager-impl.h
old mode 100644 (file)
new mode 100755 (executable)
index 5b6a98e..6df17c6
@@ -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:
 
@@ -164,7 +175,10 @@ public:
    * @param[in] maskInfo              Mask info structure
    * @param[in] synchronousLoading    true if the URL should be loaded synchronously
    * @param[out] textureId,           The textureId of the URL
-   * @param[out] textureRect          The rectangle within the texture atlas that this URL occupies
+   * @param[out] textureRect          The rectangle within the texture atlas that this URL occupies,
+   *                                  this is the rectangle in normalized coordinates.
+   * @param[out] textureRectSize      The rectangle within the texture atlas that this URL occupies,
+   *                                  this is the same rectangle in pixels.
    * @param[in,out] atlasingStatus    Set to USE_ATLAS to attempt atlasing. If atlasing fails, the image will still
    *                                  be loaded, and marked successful, but this will be set to false.
    *                                  If atlasing succeeds, this will be set to true.
@@ -192,6 +206,7 @@ public:
                           bool                         synchronousLoading,
                           TextureManager::TextureId&   textureId,
                           Vector4&                     textureRect,
+                          Dali::ImageDimensions&       textureRectSize,
                           bool&                        atlasingStatus,
                           bool&                        loadingStatus,
                           Dali::WrapMode::Type         wrapModeU,
@@ -296,9 +311,11 @@ public:
   void Remove( const TextureManager::TextureId textureId );
 
   /**
-   * Get the visualUrl associated with the texture id
+   * @brief Get the visualUrl associated with the texture id.
+   * @param[in] textureId The texture Id to get
+   * @return The visual Url associated with the texture id.
    */
-  const VisualUrl& GetVisualUrl( TextureId textureId );
+  VisualUrl GetVisualUrl( TextureId textureId );
 
   /**
    * @brief Get the current state of a texture
@@ -329,6 +346,25 @@ 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 );
+
+  /**
+   * @brief Set an image to be used when a visual has failed to correctly render
+   * @param[in] brokenImageUrl The broken image url.
+   */
+  void SetBrokenImageUrl(const std::string& brokenImageUrl);
+
 private:
 
   /**
@@ -446,12 +482,12 @@ private:
     TextureManager::TextureHash hash; ///< The hash used to cache this Texture
     float scaleFactor;             ///< The scale factor to apply to the Texture when masking
     int16_t referenceCount;        ///< The reference count of clients using this Texture
-    LoadState loadState:3;         ///< The load state showing the load progress of the Texture
+    LoadState loadState:4;         ///< The load state showing the load progress of the Texture
     FittingMode::Type fittingMode:2; ///< The requested FittingMode
     Dali::SamplingMode::Type samplingMode:3; ///< The requested SamplingMode
-    StorageType storageType:1;     ///< CPU storage / GPU upload;
+    StorageType storageType:2;     ///< CPU storage / GPU upload;
     bool loadSynchronously:1;      ///< True if synchronous loading was requested
-    UseAtlas useAtlas:1;           ///< USE_ATLAS if an atlas was requested.
+    UseAtlas useAtlas:2;           ///< USE_ATLAS if an atlas was requested.
                                    ///< This is updated to false if atlas is not used
     bool cropToMask:1;             ///< true if the image should be cropped to the mask size.
     bool orientationCorrection:1;  ///< true if the image should be rotated to match exif orientation data
@@ -710,6 +746,8 @@ 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
+  std::string                                   mBrokenImageUrl;       ///< Broken image url
   TextureId                                     mCurrentTextureId;     ///< The current value used for the unique Texture Id generation
 };