[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image-atlas-manager.h
index 45e2a54..ec7a402 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_IMAGE_ATLAS_MANAGER_H
 
 /*
- * Copyright (c) 2016 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.
  */
 
 // EXTERNAL INCLUDES
-#include <string>
+#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/rendering/texture-set.h>
+#include <string>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
+#include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 class AtlasUploadObserver;
 
 namespace Internal
 {
-
 /**
  * The manager for automatic image atlasing. Owned by VisualFactory
  */
 class ImageAtlasManager : public RefObject
 {
 public:
-  typedef std::vector< Toolkit::ImageAtlas > AtlasContainer;
-  typedef std::vector< TextureSet > TextureSetContainer;
+  typedef std::vector<Toolkit::ImageAtlas> AtlasContainer;
+  typedef std::vector<TextureSet>          TextureSetContainer;
 
 public:
-
   /**
    * Construtor
    *
@@ -55,6 +53,15 @@ public:
   ImageAtlasManager();
 
   /**
+   * @brief Check whether the image of url could be Atlas or not.
+   *
+   * @param [in] url The URL of the resource image file to use.
+   * @param [in] size The width and height to fit the loaded image to.
+   * @return True if the image could be Atlas.
+   */
+  bool CheckAtlasAvailable(const VisualUrl& url, const ImageDimensions& size) const;
+
+  /**
    * @brief Add an image to the atlas.
    *
    * @note To make the atlasing efficient, an valid size should be provided.
@@ -70,12 +77,35 @@ public:
    * @param [in] atlasUploadObserver The object to observe the uploading state inside ImageAtlas.
    * @return The texture set containing the image.
    */
-  TextureSet Add( Vector4& textureRect,
-                  const std::string& url,
-                  ImageDimensions& size,
-                  FittingMode::Type fittingMode = FittingMode::DEFAULT,
-                  bool orientationCorrection = true,
-                  AtlasUploadObserver* atlasUploadObserver = NULL );
+  TextureSet Add(Vector4&             textureRect,
+                 const VisualUrl&     url,
+                 ImageDimensions&     size,
+                 FittingMode::Type    fittingMode           = FittingMode::DEFAULT,
+                 bool                 orientationCorrection = true,
+                 AtlasUploadObserver* atlasUploadObserver   = NULL);
+
+  /**
+   * @brief Add an image to the atlas.
+   *
+   * @note To make the atlasing efficient, an valid size should be provided.
+   *
+   * SamplingMode::BOX_THEN_LINEAR is used to sampling pixels from the input image while fitting it to desired size.
+   *
+   * @param [out] textureRect The texture area of the resource image in the atlas.
+   * @param [in] encodedImageBuffer The encoded buffer of the resource image file to use.
+   * @param [in] size 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] orientationCorrection Reorient the image to respect any orientation metadata in its header.
+   * @param [in] atlasUploadObserver The object to observe the uploading state inside ImageAtlas.
+   * @return The texture set containing the image.
+   */
+  TextureSet Add(Vector4&                  textureRect,
+                 const EncodedImageBuffer& encodedImageBuffer,
+                 const ImageDimensions&    size,
+                 FittingMode::Type         fittingMode           = FittingMode::DEFAULT,
+                 bool                      orientationCorrection = true,
+                 AtlasUploadObserver*      atlasUploadObserver   = NULL);
+
   /**
    * @brief Add a pixel buffer to the atlas
    *
@@ -83,8 +113,8 @@ public:
    * @param [in] pixelData The pixel data.
    * @return The texture set containing the image.
    */
-  TextureSet Add( Vector4& textureRect,
-                  PixelData pixelData );
+  TextureSet Add(Vector4&  textureRect,
+                 PixelData pixelData);
 
   /**
    * Remove the image at the given rectangle from the texture set.
@@ -92,14 +122,14 @@ public:
    * @param [in] textureSet The texture set containing the atlas image.
    * @param [in] textureRect The texture area to be removed.
    */
-  void Remove( TextureSet textureSet, const Vector4& textureRect );
+  void Remove(TextureSet textureSet, const Vector4& textureRect);
 
   /**
    * @brief Set the broken image which is used to replace the image if loading fails.
    *
    * @param[in] brokenImageUrl The url of the broken image.
    */
-  void SetBrokenImage( const std::string& brokenImageUrl );
+  void SetBrokenImage(const std::string& brokenImageUrl);
 
   /**
    * @brief Get shader
@@ -107,7 +137,6 @@ public:
   Shader GetShader() const;
 
 private:
-
   /**
    * @brief Create a new atlas.
    *
@@ -116,7 +145,6 @@ private:
   void CreateNewAtlas();
 
 protected:
-
   /**
    * Destructor
    */
@@ -132,16 +160,13 @@ protected:
    */
   ImageAtlasManager& operator=(const ImageAtlasManager& rhs);
 
-
 private:
-
-  AtlasContainer    mAtlasList;
+  AtlasContainer      mAtlasList;
   TextureSetContainer mTextureSetList;
-  std::string       mBrokenImageUrl;
-
+  std::string         mBrokenImageUrl;
 };
 
-} // name Internal
+} // namespace Internal
 
 } // namespace Toolkit