Remove the texture element from the load queue
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / texture-manager-impl.h
index 502cf11..7d66256 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXTURE_MANAGER_IMPL_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -99,6 +99,8 @@ public:
     LOADING,         ///< Loading has been started, but not finished.
     LOAD_FINISHED,   ///< Loading has finished. (for CPU storage only)
     WAITING_FOR_MASK,///< Loading has finished, but waiting for mask image
+    MASK_APPLYING,   ///< Loading has finished, Mask is applying
+    MASK_APPLIED,    ///< Loading has finished, Mask is applyied by GPU
     UPLOADED,        ///< Uploaded and ready. (For GPU upload only)
     CANCELLED,       ///< Removed before loading completed
     LOAD_FAILED      ///< Async loading failed, e.g. connection problem
@@ -172,7 +174,7 @@ public:
    * @param[in] desiredSize           The size the image is likely to appear at. This can be set to 0,0 for automatic
    * @param[in] fittingMode           The FittingMode to use
    * @param[in] samplingMode          The SamplingMode to use
-   * @param[in] maskInfo              Mask info structure
+   * @param[in, out] 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,
@@ -202,7 +204,7 @@ public:
                           Dali::ImageDimensions        desiredSize,
                           Dali::FittingMode::Type      fittingMode,
                           Dali::SamplingMode::Type     samplingMode,
-                          const MaskingDataPointer&    maskInfo,
+                          MaskingDataPointer&          maskInfo,
                           bool                         synchronousLoading,
                           TextureManager::TextureId&   textureId,
                           Vector4&                     textureRect,
@@ -307,8 +309,9 @@ public:
    * occurrence of a Texture will cause its removal internally.
    *
    * @param[in] textureId The ID of the Texture to remove.
+   * @param[in] textureObserver The texture observer.
    */
-  void Remove( const TextureManager::TextureId textureId );
+  void Remove( const TextureManager::TextureId textureId, TextureUploadObserver* textureObserver );
 
   /**
    * @brief Get the visualUrl associated with the texture id.
@@ -605,13 +608,10 @@ private:
 
   /**
    * Apply the mask to the pixelBuffer.
-   * @param[in] pixelBuffer The pixelBuffer to apply the mask to
+   * @param[in] textureInfo The information of texture to apply the mask to
    * @param[in] maskTextureId The texture id of the mask.
-   * @param[in] contentScale The factor to scale the content
-   * @param[in] cropToMask Whether to crop the content to the mask size
    */
-  void ApplyMask( Devel::PixelBuffer& pixelBuffer, TextureId maskTextureId,
-                  float contentScale, bool cropToMask );
+  void ApplyMask( TextureInfo& textureInfo, TextureId maskTextureId );
 
   /**
    * Upload the texture specified in pixelBuffer to the appropriate location
@@ -665,8 +665,8 @@ private:
   TextureHash GenerateHash( const std::string& url, const ImageDimensions size,
                             const FittingMode::Type fittingMode,
                             const Dali::SamplingMode::Type samplingMode, const UseAtlas useAtlas,
-                            TextureId maskTextureId,
-                            MultiplyOnLoad preMultiplyOnLoad);
+                            TextureId maskTextureId );
+
   /**
    * @brief Looks up a cached texture by its hash.
    * If found, the given parameters are used to check there is no hash-collision.
@@ -713,13 +713,31 @@ private:
      * @param[in] samplingMode          The SamplingMode to use
      * @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image,
      *                                  e.g., from portrait to landscape
+     * @param[in] preMultiplyOnLoad     if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask.
      */
     void Load(TextureId textureId,
               const VisualUrl& url,
               ImageDimensions desiredSize,
               FittingMode::Type fittingMode,
               SamplingMode::Type samplingMode,
-              bool orientationCorrection);
+              bool orientationCorrection,
+              DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
+
+    /**
+     * @brief Apply mask
+     * @param [in] id of the texture
+     * @param [in] pixelBuffer of the to be masked image
+     * @param [in] maskPixelBuffer of the mask image
+     * @param [in] contentScale The factor to scale the content
+     * @param [in] cropToMask Whether to crop the content to the mask size
+     * @param [in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha.
+     */
+    void ApplyMask( TextureId textureId,
+                    Devel::PixelBuffer pixelBuffer,
+                    Devel::PixelBuffer maskPixelBuffer,
+                    float contentScale,
+                    bool cropToMask,
+                    DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
 
   public:
     AsyncLoadingHelper(const AsyncLoadingHelper&) = delete;
@@ -732,16 +750,16 @@ private:
     /**
      * @brief Main constructor that used by all other constructors
      */
-    AsyncLoadingHelper(Toolkit::AsyncImageLoader loader,
-                       TextureManager& textureManager,
-                       AsyncLoadingInfoContainerType&& loadingInfoContainer);
+    AsyncLoadingHelper( Toolkit::AsyncImageLoader loader,
+                        TextureManager& textureManager,
+                        AsyncLoadingInfoContainerType&& loadingInfoContainer );
 
     /**
      * @brief Callback to be called when texture loading is complete, it passes the pixel buffer on to texture manager.
      * @param[in] id          Loader id
      * @param[in] pixelBuffer Image data
      */
-    void AsyncLoadComplete(uint32_t id, Devel::PixelBuffer pixelBuffer);
+    void AsyncLoadComplete( uint32_t id, Devel::PixelBuffer pixelBuffer );
 
   private:
     Toolkit::AsyncImageLoader     mLoader;