[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / texture-manager / texture-async-loading-helper.h
index 4bfc961..a8fddbf 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TEXTURE_ASYNC_LOADING_HELPER_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/signals/connection-tracker.h>
-#include <deque>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
+#include <dali-toolkit/internal/image-loader/loading-task.h>
 #include <dali-toolkit/internal/texture-manager/texture-manager-impl.h>
 
 namespace Dali
@@ -36,22 +35,6 @@ namespace Internal
  */
 class TextureAsyncLoadingHelper : public ConnectionTracker
 {
-  /**
-   * Struct to hold information about a requested Async load.
-   * This is used to look up a TextureManager::TextureId from the returned AsyncLoad Id.
-   */
-  struct AsyncLoadingInfo
-  {
-    AsyncLoadingInfo(TextureManager::TextureId textureId)
-    : textureId(textureId),
-      loadId(0)
-    {
-    }
-
-    TextureManager::TextureId textureId; ///< The external Texture Id assigned to this load
-    std::uint32_t             loadId;    ///< The load Id used by the async loader to reference this load
-  };
-
 public:
   /**
    * @brief Create an TextureAsyncLoadingHelper.
@@ -64,10 +47,19 @@ public:
    * @param[in] textureId             TextureId to reference the texture that will be loaded
    * @param[in] animatedImageLoading  The AnimatedImageLoading to load animated image
    * @param[in] frameIndex            The frame index of a frame to be loaded frame
+   * @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] 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 LoadAnimatedImage(const TextureManager::TextureId& textureId,
-                         Dali::AnimatedImageLoading       animatedImageLoading,
-                         const std::uint32_t&             frameIndex);
+  void LoadAnimatedImage(const TextureManager::TextureId                textureId,
+                         Dali::AnimatedImageLoading                     animatedImageLoading,
+                         const uint32_t                                 frameIndex,
+                         const Dali::ImageDimensions&                   desiredSize,
+                         const Dali::FittingMode::Type                  fittingMode,
+                         const Dali::SamplingMode::Type                 samplingMode,
+                         const DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
 
   /**
    * @brief Load a new texture.
@@ -80,14 +72,16 @@ public:
    * @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.
+   * @param[in] loadYuvPlanes         True if the image should be loaded as yuv planes
    */
-  void Load(const TextureManager::TextureId&                textureId,
-            const VisualUrl&                                url,
-            const Dali::ImageDimensions&                    desiredSize,
-            const Dali::FittingMode::Type&                  fittingMode,
-            const Dali::SamplingMode::Type&                 samplingMode,
-            const bool&                                     orientationCorrection,
-            const DevelAsyncImageLoader::PreMultiplyOnLoad& preMultiplyOnLoad);
+  void Load(const TextureManager::TextureId                textureId,
+            const VisualUrl&                               url,
+            const Dali::ImageDimensions&                   desiredSize,
+            const Dali::FittingMode::Type                  fittingMode,
+            const Dali::SamplingMode::Type                 samplingMode,
+            const bool                                     orientationCorrection,
+            const DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad,
+            const bool                                     loadYuvPlanes);
 
   /**
    * @brief Apply mask
@@ -98,42 +92,27 @@ public:
    * @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(const TextureManager::TextureId&                textureId,
-                 Devel::PixelBuffer                              pixelBuffer,
-                 Devel::PixelBuffer                              maskPixelBuffer,
-                 const float&                                    contentScale,
-                 const bool&                                     cropToMask,
-                 const DevelAsyncImageLoader::PreMultiplyOnLoad& preMultiplyOnLoad);
+  void ApplyMask(const TextureManager::TextureId                textureId,
+                 Devel::PixelBuffer                             pixelBuffer,
+                 Devel::PixelBuffer                             maskPixelBuffer,
+                 const float                                    contentScale,
+                 const bool                                     cropToMask,
+                 const DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
 
 public:
   TextureAsyncLoadingHelper(const TextureAsyncLoadingHelper&) = delete;
   TextureAsyncLoadingHelper& operator=(const TextureAsyncLoadingHelper&) = delete;
 
-  TextureAsyncLoadingHelper(TextureAsyncLoadingHelper&& rhs);
-  TextureAsyncLoadingHelper& operator=(TextureAsyncLoadingHelper&& rhs) = delete;
-
-private:                                                              // Private typedefs:
-  typedef std::deque<AsyncLoadingInfo> AsyncLoadingInfoContainerType; ///< The container type used to manage Asynchronous loads in progress
-
 private:
   /**
-   * @brief Main constructor that used by all other constructors
-   */
-  TextureAsyncLoadingHelper(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
+   * @brief Callback to be called when texture loading is complete, it passes the pixel buffer list on to texture manager.
+   * @param[in] task LoadingTaskPtr
    */
-  void AsyncLoadComplete(std::uint32_t id, Devel::PixelBuffer pixelBuffer);
+  void AsyncLoadComplete(LoadingTaskPtr task);
 
 private: // Member Variables:
-  Toolkit::AsyncImageLoader     mLoader;
-  TextureManager&               mTextureManager;
-  AsyncLoadingInfoContainerType mLoadingInfoContainer;
+  TextureManager& mTextureManager;
+  uint32_t        mLoadTaskId;
 };
 
 } // namespace Internal