Reduce default visual-base-data memory - Allocate only if we use decoration.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / async-image-loader-impl.h
index 34496b1..c23b102 100644 (file)
@@ -23,7 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
-#include <dali-toolkit/internal/image-loader/image-load-thread.h>
+#include <dali-toolkit/internal/image-loader/loading-task.h>
 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
 
 namespace Dali
@@ -32,7 +32,21 @@ namespace Toolkit
 {
 namespace Internal
 {
-class AsyncImageLoader : public BaseObject
+using LoadingTaskPtr = IntrusivePtr<LoadingTask>;
+
+struct AsyncImageLoadingInfo
+{
+  AsyncImageLoadingInfo(LoadingTaskPtr loadingTask, std::uint32_t loadId)
+  : loadingTask(loadingTask),
+    loadId(loadId)
+  {
+  }
+
+  LoadingTaskPtr loadingTask;
+  std::uint32_t  loadId;
+};
+
+class AsyncImageLoader : public BaseObject, public ConnectionTracker
 {
 public:
   /**
@@ -53,6 +67,24 @@ public:
                              DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
 
   /**
+   * @brief Starts an animated image loading task.
+   * @param[in] asyncImageLoader The ayncImageLoader
+   * @param[in] animatedImageLoading The AnimatedImageLoading to load animated image
+   * @param[in] frameIndex The frame index of a frame to be loaded frame
+   * @param[in] dimensions The width and height to fit the loaded image to
+   * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
+   * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
+   * @param[in] preMultiplyOnLoad ON if the image 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.
+   * @return The loading task id
+   */
+  uint32_t LoadAnimatedImage(Dali::AnimatedImageLoading               animatedImageLoading,
+                             uint32_t                                 frameIndex,
+                             Dali::ImageDimensions                    desiredSize,
+                             Dali::FittingMode::Type                  fittingMode,
+                             Dali::SamplingMode::Type                 samplingMode,
+                             DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
+
+  /**
    * @brief Starts an image loading task.
    * @param[in] url The URL of the image file to load
    * @param[in] dimensions The width and height to fit the loaded image to
@@ -126,7 +158,7 @@ public:
   /**
    * Process the completed loading task from the worker thread.
    */
-  void ProcessLoadedImage();
+  void ProcessLoadedImage(LoadingTaskPtr task);
 
 protected:
   /**
@@ -135,12 +167,17 @@ protected:
   ~AsyncImageLoader() override;
 
 private:
+  /**
+   * Remove already completed tasks
+   */
+  void RemoveCompletedTask();
+
+private:
   Toolkit::AsyncImageLoader::ImageLoadedSignalType            mLoadedSignal;
   Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType mPixelBufferLoadedSignal;
-
-  ImageLoadThread mLoadThread;
-  uint32_t        mLoadTaskId;
-  bool            mIsLoadThreadStarted;
+  std::vector<AsyncImageLoadingInfo>                          mLoadingTasks;
+  std::vector<uint32_t>                                       mCompletedTaskIds;
+  uint32_t                                                    mLoadTaskId;
 };
 
 } // namespace Internal