Changed 'virtual' function override declarations to 'override' in dali-toolkit.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / image-loader / image-load-thread.h
index f3d9632..27c8850 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__
-#define __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__
+#ifndef DALI_TOOLKIT_IMAGE_LOAD_THREAD_H
+#define DALI_TOOLKIT_IMAGE_LOAD_THREAD_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 #include <dali/public-api/common/dali-vector.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/pixel-data.h>
 #include <dali/devel-api/threading/conditional-wait.h>
 #include <dali/devel-api/threading/mutex.h>
 #include <dali/devel-api/threading/thread.h>
 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali-toolkit/internal/visuals/visual-url.h>
+#include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
+#include <dali/integration-api/adaptor-framework/log-factory-interface.h>
 
 namespace Dali
 {
@@ -45,21 +47,62 @@ struct LoadingTask
   /**
    * Constructor.
    * @param [in] id of the task
+   * @param [in] animatedImageLoading The AnimatedImageLoading to load animated image
+   * @param [in] frameIndex The frame index of a frame to be loaded frame
+   */
+  LoadingTask( uint32_t id,
+               Dali::AnimatedImageLoading animatedImageLoading,
+               uint32_t frameIndex );
+
+  /**
+   * Constructor.
+   * @param [in] id of the task
    * @param [in] url The URL of the image file to load.
    * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image
    * @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] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+   * @param [in] preMultiplyOnLoad ON 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.
+   */
+  LoadingTask( uint32_t id,
+               const VisualUrl& url,
+               ImageDimensions dimensions,
+               FittingMode::Type fittingMode,
+               SamplingMode::Type samplingMode,
+               bool orientationCorrection,
+               DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
+
+  /**
+   * Constructor.
+   * @param [in] id of the task
+   * @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 ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha.
    */
-  LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dimensions,
-               FittingMode::Type fittingMode, SamplingMode::Type samplingMode,
-               bool orientationCorrection );
+  LoadingTask( uint32_t id,
+               Devel::PixelBuffer pixelBuffer,
+               Devel::PixelBuffer maskPixelBuffer,
+               float contentScale,
+               bool cropToMask,
+               DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
 
   /**
    * Load the image
    */
   void Load();
 
+  /**
+   * Apply mask
+   */
+  void ApplyMask();
+
+  /**
+   * Multiply alpha
+   */
+  void MultiplyAlpha();
+
 private:
 
   // Undefined
@@ -70,14 +113,22 @@ private:
 
 public:
 
-  PixelData          pixelData;     ///< pixelData handle after successfull load
+  Devel::PixelBuffer pixelBuffer;   ///< pixelBuffer handle after successful load
+                                    ///< or pixelBuffer to be masked image in the mask task
   VisualUrl          url;           ///< url of the image to load
   uint32_t           id;            ///< The unique id associated with this task.
   ImageDimensions    dimensions;    ///< dimensions to load
   FittingMode::Type  fittingMode;   ///< fitting options
   SamplingMode::Type samplingMode;  ///< sampling options
   bool               orientationCorrection:1; ///< if orientation correction is needed
-
+  DevelAsyncImageLoader::PreMultiplyOnLoad            preMultiplyOnLoad; //< if the image's color should be multiplied by it's alpha
+
+  bool isMaskTask;                  ///< whether this task is for mask or not
+  Devel::PixelBuffer maskPixelBuffer; ///< pixelBuffer of mask image
+  float contentScale;               ///< The factor to scale the content
+  bool cropToMask;                  ///< Whether to crop the content to the mask size
+  Dali::AnimatedImageLoading animatedImageLoading;
+  uint32_t frameIndex;
 };
 
 
@@ -148,7 +199,7 @@ protected:
    * The entry function of the worker thread.
    * It fetches loading task from the loadQueue, loads the image and adds to the completeQueue.
    */
-  virtual void Run();
+  void Run() override;
 
 private:
 
@@ -162,10 +213,11 @@ private:
 
   Vector< LoadingTask* > mLoadQueue;     ///<The task queue with images for loading.
   Vector< LoadingTask* > mCompleteQueue; ///<The task queue with images loaded.
+  EventThreadCallback*   mTrigger;
+  const Dali::LogFactoryInterface& mLogFactory; ///< The log factory
 
   ConditionalWait        mConditionalWait;
   Dali::Mutex            mMutex;
-  EventThreadCallback*   mTrigger;
 };
 
 } // namespace Internal
@@ -174,4 +226,4 @@ private:
 
 } // namespace Dali
 
-#endif /* __DALI_TOOLKIT_IMAGE_LOAD_THREAD_H__ */
+#endif // DALI_TOOLKIT_IMAGE_LOAD_THREAD_H