Remove mask internally in texture manager
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / texture-manager / texture-manager-impl.h
index ee1f065..601cbea 100644 (file)
@@ -80,6 +80,8 @@ public:
     TextureManager::TextureId mAlphaMaskId;
     float                     mContentScaleFactor;
     bool                      mCropToMask;
+    bool                      mPreappliedMasking;
+    bool                      mMaskImageLoadingFailed;
   };
   using MaskingDataPointer = std::unique_ptr<MaskingData>;
 
@@ -112,28 +114,33 @@ public:
    * The parameters are used to specify how the animated image is loaded.
    * The observer has the LoadComplete method called when the load is ready.
    *
+   * @param[in]  url                   The URL of the image to load
    * @param[in]  animatedImageLoading  The AnimatedImageLoading that contain the animated image information
    * @param[in]  frameIndex            The frame index to load.
    * @param[out] textureId             The textureId of the frame
+   * @param[in, out] maskInfo          Mask info structure
    * @param[in]  samplingMode          The SamplingMode to use
    * @param[in]  wrapModeU             Horizontal Wrap mode
    * @param[in]  wrapModeV             Vertical Wrap mode
    * @param[in]  synchronousLoading    true if the frame should be loaded synchronously
-   * @param[in]  useCache              true if this frame loading uses cache.
    * @param[in]  textureObserver       The client object should inherit from this and provide the "LoadCompleted" virtual.
    *                                   This is called when an image load completes (or fails).
+   * @param[in,out] preMultiplyOnLoad  True if the image color should be multiplied by it's alpha. Set to false if the
+   *                                   image has no alpha channel
    *
    * @return                           The texture set containing the frame of animated image, or empty if still loading.
    */
-  TextureSet LoadAnimatedImageTexture(Dali::AnimatedImageLoading      animatedImageLoading,
+  TextureSet LoadAnimatedImageTexture(const VisualUrl&                url,
+                                      Dali::AnimatedImageLoading      animatedImageLoading,
                                       const uint32_t&                 frameIndex,
                                       TextureManager::TextureId&      textureId,
+                                      MaskingDataPointer&             maskInfo,
                                       const Dali::SamplingMode::Type& samplingMode,
                                       const Dali::WrapMode::Type&     wrapModeU,
                                       const Dali::WrapMode::Type&     wrapModeV,
                                       const bool&                     synchronousLoading,
-                                      const bool&                     useCache,
-                                      TextureUploadObserver*          textureObserver);
+                                      TextureUploadObserver*          textureObserver,
+                                      TextureManager::MultiplyOnLoad& preMultiplyOnLoad);
 
   /**
    * @brief Requests an image load of the given URL to get PixelBuffer.
@@ -411,12 +418,14 @@ public: // Load Request API
    * @brief Requests a masking image to be loaded. This mask is not uploaded to GL,
    * instead, it is stored in CPU memory, and can be used for CPU blending.
    * @param[in] maskUrl            The URL of the mask image to load
+   * @param[in] storageType,       Whether the pixel data is stored in the cache or uploaded to the GPU
    * @param[in] synchronousLoading True if the frame should be loaded synchronously. If you skip this parameter,
    *                               default is false.
    * @return                       A TextureId to use as a handle to reference this mask Texture
    */
   TextureId RequestMaskLoad(
     const VisualUrl& maskUrl,
+    StorageType      storageType,
     const bool&      synchronousLoading = false);
 
 private:
@@ -454,7 +463,6 @@ private:
    * @param[in] frameIndex            The frame index of a frame to be loaded frame
    * @param[in] synchronousLoading    True if the frame should be loaded synchronously. If you skip this parameter,
    *                                  default is false.
-   * @param[in] useCache              True if the texture will be cached.
    * @return                          A TextureId to use as a handle to reference this Texture
    */
   TextureId RequestLoadInternal(
@@ -473,8 +481,7 @@ private:
     TextureManager::MultiplyOnLoad&     preMultiplyOnLoad,
     Dali::AnimatedImageLoading          animatedImageLoading,
     const std::uint32_t&                frameIndex,
-    const bool&                         synchronousLoading,
-    const bool&                         useCache);
+    const bool&                         synchronousLoading);
 
   /**
    * @brief Load a new image synchronously.
@@ -485,14 +492,18 @@ 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] loadYuvPlanes         True if the image should be loaded as yuv planes
+   * @param[out] pixelBuffers         The image pixelBuffer
    * @return PixelBuffer of loaded image.
    */
-  Devel::PixelBuffer LoadImageSynchronously(
-    const VisualUrl&                url,
-    const Dali::ImageDimensions&    desiredSize,
-    const Dali::FittingMode::Type&  fittingMode,
-    const Dali::SamplingMode::Type& samplingMode,
-    const bool&                     orientationCorrection);
+  void LoadImageSynchronously(
+    const VisualUrl&                 url,
+    const Dali::ImageDimensions&     desiredSize,
+    const Dali::FittingMode::Type&   fittingMode,
+    const Dali::SamplingMode::Type&  samplingMode,
+    const bool&                      orientationCorrection,
+    const bool&                      loadYuvPlanes,
+    std::vector<Devel::PixelBuffer>& pixelBuffers);
 
 private:
   // Load and queue
@@ -500,9 +511,9 @@ private:
   /**
    * Structure to hold info about a texture load queued during NotifyObservers
    */
-  struct LoadQueueElement
+  struct QueueElement
   {
-    LoadQueueElement(TextureManager::TextureId textureId, TextureUploadObserver* observer)
+    QueueElement(TextureManager::TextureId textureId, TextureUploadObserver* observer)
     : mTextureId(textureId),
       mObserver(observer)
     {
@@ -552,11 +563,11 @@ private:
 
   /**
    * @brief Performs Post-Load steps including atlasing.
-   * @param[in] textureInfo The struct associated with this Texture
-   * @param[in] pixelBuffer The image pixelBuffer
+   * @param[in] textureInfo  The struct associated with this Texture
+   * @param[in] pixelBuffers The image pixelBuffer
    * @return    True if successful
    */
-  void PostLoad(TextureManager::TextureInfo& textureInfo, Devel::PixelBuffer& pixelBuffer);
+  void PostLoad(TextureManager::TextureInfo& textureInfo, std::vector<Devel::PixelBuffer>& pixelBuffers);
 
   /**
    * Check if there is a texture waiting to be masked. If there
@@ -574,11 +585,10 @@ private:
 
   /**
    * Upload the texture specified in pixelBuffer to the appropriate location
-   * @param[in] pixelBuffer The image data to upload
-   * @param[in] textureInfo The texture info containing the location to
-   * store the data to.
+   * @param[in] pixelBuffers The image data to upload
+   * @param[in] textureInfo  The texture info containing the location to store the data to.
    */
-  void UploadTexture(Devel::PixelBuffer& pixelBuffer, TextureManager::TextureInfo& textureInfo);
+  void UploadTextures(std::vector<Devel::PixelBuffer>& pixelBuffers, TextureManager::TextureInfo& textureInfo);
 
   /**
    * Notify the current observers that the texture upload is complete,
@@ -596,14 +606,23 @@ private:
    */
   void EmitLoadComplete(TextureUploadObserver* observer, TextureManager::TextureInfo& textureInfo, const bool& success);
 
+
+  /**
+   * @brief Remove observer in textureInfo
+   *
+   * @param textureInfo The struct associated with this Texture.
+   * @param observer The observer wishing to remove.
+   */
+  void RemoveTextureObserver(TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer);
+
 public:
   /**
    * @brief Common method to handle loading completion.
    * TextureAsyncLoadingHelper will call this API After async loading finished.
-   * @param[in] textureId   The ID of the texture load complete.
-   * @param[in] pixelBuffer The loaded image data
+   * @param[in] textureId    The ID of the texture load complete.
+   * @param[in] pixelBuffers The loaded image data
    */
-  void AsyncLoadComplete(const TextureManager::TextureId& textureId, Devel::PixelBuffer pixelBuffer);
+  void AsyncLoadComplete(const TextureManager::TextureId& textureId, std::vector<Devel::PixelBuffer>& pixelBuffers);
 
 private:
   /**
@@ -629,10 +648,11 @@ private:                                    // Member Variables:
   RoundRobinContainerView<TextureAsyncLoadingHelper> mAsyncLocalLoaders;  ///< The Asynchronous image loaders used to provide all local async loads
   RoundRobinContainerView<TextureAsyncLoadingHelper> mAsyncRemoteLoaders; ///< The Asynchronous image loaders used to provide all remote async loads
 
-  Dali::Vector<LifecycleObserver*>        mLifecycleObservers; ///< Lifecycle observers of texture manager
-  Dali::Vector<LoadQueueElement>          mLoadQueue;          ///< Queue of textures to load after NotifyObservers
-  Dali::Vector<TextureManager::TextureId> mRemoveQueue;        ///< Queue of textures to remove after NotifyObservers
-  bool                                    mQueueLoadFlag;      ///< Flag that causes Load Textures to be queued.
+  Dali::Vector<LifecycleObserver*>        mLifecycleObservers;      ///< Lifecycle observers of texture manager
+  Dali::Vector<QueueElement>              mLoadQueue;               ///< Queue of textures to load after NotifyObservers
+  Dali::Vector<QueueElement>              mRemoveQueue;             ///< Queue of textures to remove after NotifyObservers
+  TextureManager::TextureId               mLoadingQueueTextureId;   ///< TextureId when it is loading. it causes Load Textures to be queued.
+  bool                                    mLoadYuvPlanes;           ///< A global flag to specify if the image should be loaded as yuv planes
 };
 
 } // namespace Internal