Merge "Add support for FontClient PreCache in candidate process" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / animated-image-loading.h
index 7c0a69b..2f07eb9 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ANIMATED_IMAGE_LOADING_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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/vector-wrapper.h>
 #include <dali/public-api/math/uint-16-pair.h>
 #include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/images/image-operations.h>
 
 // INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali/public-api/dali-adaptor-common.h>
 
 namespace Dali
 {
-
 class PixelData;
 typedef Dali::Uint16Pair ImageDimensions;
 
@@ -43,7 +44,7 @@ namespace Adaptor
 {
 class AnimatedImageLoading;
 }
-}
+} // namespace DALI_INTERNAL
 
 /**
  * Class to manage loading frames of an animated image in small chunks. Lazy initializes only when
@@ -55,14 +56,13 @@ class AnimatedImageLoading;
 class DALI_ADAPTOR_API AnimatedImageLoading : public BaseHandle
 {
 public:
-
   /**
    * Create a GifLoading with the given url and resourceType.
    * @param[in] url The url of the animated image to load
    * @param[in] isLocalResource The true or false whether this is a local resource.
    * @return A newly created GifLoading.
    */
-  static AnimatedImageLoading New( const std::string& url, bool isLocalResource );
+  static AnimatedImageLoading New(const std::string& url, bool isLocalResource);
 
   /**
    * @brief Constructor
@@ -78,8 +78,7 @@ public:
    * @param[in] handle to An object.
    * @return handle to a Capture object or an uninitialized handle.
    */
-  static AnimatedImageLoading DownCast( BaseHandle handle );
-
+  static AnimatedImageLoading DownCast(BaseHandle handle);
 
   /**
    * @brief Copy constructor.
@@ -97,21 +96,40 @@ public:
   AnimatedImageLoading& operator=(const AnimatedImageLoading& rhs) = default;
 
   /**
+   * @brief Move constructor.
+   *
+   * @param[in] move The AnimatedImageLoading to move
+   */
+  AnimatedImageLoading(AnimatedImageLoading&& move) = default;
+
+  /**
+   * @brief Move assignment operator
+   *
+   * @param[in] rhs The AnimatedImageLoading to move
+   * @return A reference to this
+   */
+  AnimatedImageLoading& operator=(AnimatedImageLoading&& rhs) = default;
+
+  /**
    * @brief Destructor
    */
   ~AnimatedImageLoading();
 
   /**
-   * @brief Load the next N Frames of the animated image.
+   * @brief Load a frame of the animated image.
    *
    * @note This function will load the entire animated image into memory if not already loaded.
-   * @param[in] frameStartIndex The frame counter to start from. Will usually be the next frame
-   * after the previous invocation of this method, or 0 to start.
-   * @param[in] count The number of frames to load
-   * @param[out] pixelData The vector in which to return the frame data
-   * @return True if the frame data was successfully loaded
+   * @param[in] frameIndex The frame index to load.
+   * @param[in] size The width and height to fit the loaded image to.
+   * @param[in] fittingMode The FittingMode of the resource to load
+   * @param[in] samplingMode The SamplingMode of the resource to load
+   *
+   * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle.
    */
-  bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData );
+  Dali::Devel::PixelBuffer LoadFrame(uint32_t                 frameIndex,
+                                     ImageDimensions          size = ImageDimensions(),
+                                     Dali::FittingMode::Type  fittingMode = Dali::FittingMode::SCALE_TO_FILL,
+                                     Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::BOX_THEN_LINEAR);
 
   /**
    * @brief Get the size of a animated image.
@@ -132,7 +150,21 @@ public:
    *
    * @return The time interval of the frame(microsecond).
    */
-  uint32_t GetFrameInterval( uint32_t frameIndex ) const;
+  uint32_t GetFrameInterval(uint32_t frameIndex) const;
+
+  /**
+   * @brief Get the animated image file URL
+   *
+   * @return The URL string of the animated image file
+   */
+  std::string GetUrl() const;
+
+  /**
+   * @brief Return whether the animated image loading is succeeded or not.
+   *
+   * @return True when the animated image loading is succeeded.
+   */
+  bool HasLoadingSucceeded() const;
 
 public: // Not intended for application developers
   /// @cond internal
@@ -141,7 +173,7 @@ public: // Not intended for application developers
    *
    * @param[in] internal A pointer to a newly allocated Dali resource.
    */
-  explicit DALI_INTERNAL AnimatedImageLoading( Internal::Adaptor::AnimatedImageLoading* internal );
+  explicit DALI_INTERNAL AnimatedImageLoading(Internal::Adaptor::AnimatedImageLoading* internal);
   /// @endcond
 };