Merge "Add text selection popup style" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-url.h
index f3af2e0..941d0b8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
 
 /*
- * Copyright (c) 2017 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.
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal
 {
-
 class VisualUrl
 {
 public:
-
   /**
    * The type of the URL based on the string contents
    */
@@ -41,14 +37,17 @@ public:
     N_PATCH,
     SVG,
     GIF,
-    JSON
+    WEBP,
+    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
   };
 
   /**
@@ -58,23 +57,31 @@ public:
   VisualUrl();
 
   /**
+   * Default Destructor.
+   * Delete an external texture if if protocolType is TEXTURE.
+   */
+  ~VisualUrl();
+
+  /**
    * Constructor.
    * Determines type of visual and whether the url is local or remote
+   * Notify that it is using an external texture if if protocolType is TEXTURE.
+   *
    * @param[in] url The URL to store and resolve
    */
-  VisualUrl( const std::string& url );
+  VisualUrl(const std::string& url);
 
   /**
    * Copy constructor
    * @param[in] url The VisualUrl to copy
    */
-  VisualUrl( const VisualUrl& url );
+  VisualUrl(const VisualUrl& url);
 
   /**
    * Assignment operator
    * @param[in] url The VisualUrl to copy
    */
-  VisualUrl& operator=( const VisualUrl& url );
+  VisualUrl& operator=(const VisualUrl& url);
 
   /**
    * Get the full URL
@@ -83,6 +90,12 @@ public:
   const std::string& GetUrl() const;
 
   /**
+   * Get the hash value of full URL
+   * @return The hash value of url
+   */
+  const std::uint64_t& GetUrlHash() const;
+
+  /**
    * Get the visual type of the URL
    * @return The visual type of the URL
    */
@@ -106,6 +119,11 @@ 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;
@@ -115,14 +133,36 @@ public:
    * @param location the location of the texture
    * @return the Url
    */
-  static std::string CreateTextureUrl( const std::string& location );
+  static std::string CreateTextureUrl(const std::string& location);
+
+  /**
+   * Helper to create a URL of type BUFFER
+   * @param location the location of the texture
+   * @return the Url
+   */
+  static std::string CreateBufferUrl(const std::string& location);
+
+  /**
+   * Helper to get a ProtocolType from url
+   * @param url the url of the texture
+   * @return the protocol type
+   */
+  static VisualUrl::ProtocolType GetProtocolType(const std::string& url);
+
+  /**
+   * Helper to get a location from url
+   * @param url the location of the texture
+   * @return the location
+   */
+  static std::string GetLocation(const std::string& url);
 
 private:
-  std::string mUrl;
-  Type mType;
+  std::string  mUrl;
+  Type         mType;
   ProtocolType mLocation;
-};
 
+  mutable std::uint64_t mUrlHash;
+};
 
 } // namespace Internal