[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-url.h
index a772bd1..8caf716 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
  * limitations under the License.
  */
 
+// EXTERNAL INCLUDES
+#include <cstdint>
 #include <string>
+#include <string_view>
 
 namespace Dali
 {
@@ -38,14 +41,16 @@ public:
     SVG,
     GIF,
     WEBP,
-    JSON
+    JSON,
+    TVG
   };
 
   enum ProtocolType
   {
     LOCAL,   ///< file in local file system
     TEXTURE, ///< texture uploaded to texture manager
-    REMOTE   ///< remote image
+    REMOTE,  ///< remote image
+    BUFFER   ///< encoded image buffer
   };
 
   /**
@@ -82,12 +87,36 @@ public:
   VisualUrl& operator=(const VisualUrl& url);
 
   /**
+   * Move constructor
+   * @param[in] url The VisualUrl to move
+   */
+  VisualUrl(VisualUrl&& url) noexcept;
+
+  /**
+   * Move assignment operator
+   * @param[in] url The VisualUrl to move
+   */
+  VisualUrl& operator=(VisualUrl&& url) noexcept;
+
+  /**
    * Get the full URL
    * @return The url
    */
   const std::string& GetUrl() const;
 
   /**
+   * Get the ellipsed URL.
+   * @return The ellipsed url
+   */
+  std::string GetEllipsedUrl() const;
+
+  /**
+   * Get the hash value of full URL
+   * @return The hash value of url
+   */
+  std::uint64_t GetUrlHash() const;
+
+  /**
    * Get the visual type of the URL
    * @return The visual type of the URL
    */
@@ -111,11 +140,21 @@ public:
   bool IsLocalResource() const;
 
   /**
+   * @return true if the location is BUFFER, i.e. may contain EncodedImageBuffer
+   */
+  bool IsBufferResource() const;
+
+  /**
    * @return the location part of the url
    */
   std::string GetLocation() const;
 
   /**
+   * @return the location part of the url without extension
+   */
+  std::string GetLocationWithoutExtension() const;
+
+  /**
    * Helper to create a URL of type TEXTURE
    * @param location the location of the texture
    * @return the Url
@@ -123,6 +162,14 @@ public:
   static std::string CreateTextureUrl(const std::string& location);
 
   /**
+   * Helper to create a URL of type BUFFER
+   * @param[in] location the location of the texture
+   * @param[in] extension the extension of url
+   * @return the Url
+   */
+  static std::string CreateBufferUrl(const std::string& location, const std::string_view& extension);
+
+  /**
    * Helper to get a ProtocolType from url
    * @param url the url of the texture
    * @return the protocol type
@@ -135,10 +182,20 @@ public:
    * @return the location
    */
   static std::string GetLocation(const std::string& url);
+
+  /**
+   * Helper to get a location from url without extension
+   * @param[in] url the location of the texture
+   * @return the location without extension
+   */
+  static std::string GetLocationWithoutExtension(const std::string& url);
+
 private:
   std::string  mUrl;
   Type         mType;
   ProtocolType mLocation;
+
+  mutable std::uint64_t mUrlHash;
 };
 
 } // namespace Internal