Generate url and load texture from encoded image buffer
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / image-loader / image-url.h
1 #ifndef DALI_TOOLKIT_IMAGE_URL_H
2 #define DALI_TOOLKIT_IMAGE_URL_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <string>
22 #include <dali/public-api/rendering/texture.h>
23 #include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/dali-toolkit-common.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace Internal DALI_INTERNAL
33 {
34 class ImageUrl;
35 }
36 /**
37  * @brief ImageUrl can be used to wrap an external buffer.
38  *
39  * An instance of ImageUrl can be created from Image::GenerateUrl().
40  * Application can get url from ImageUrl.
41  * When application does not use this anymore, the destructor of the ImageUrl is called.
42  * At this time, the buffer is deleted from the texture manager.
43  * @note Visual also have reference of the buffer. In this case, buffer will be deleted after visual is deleted.
44  */
45 class DALI_TOOLKIT_API ImageUrl : public BaseHandle
46 {
47 public:
48   /**
49    * Default Constructor.
50    * Resulting URL is not valid
51    */
52   ImageUrl();
53
54   /**
55    * Destructor
56    */
57   ~ImageUrl();
58
59   /**
60    * @brief Create an initialized ImageUrl.
61    *
62    * @param[in] texture The texture url is got from external buffer.
63    * @return A handle to a newly allocated Dali resource.
64    */
65   static ImageUrl New(Texture& texture);
66
67   /**
68    * @brief Create an initialized ImageUrl.
69    *
70    * @param[in] encodedImageBuffer The encoded image buffer url is got from external buffer.
71    * @return A handle to a newly allocated Dali resource.
72    */
73   static ImageUrl New(const EncodedImageBuffer& encodedImageBuffer);
74
75   /**
76    * @brief Downcast an Object handle to ImageUrl handle.
77    *
78    * If handle points to a ImageUrl object the downcast produces valid
79    * handle. If not the returned handle is left uninitialized.
80    *
81    * @param[in] handle to An object.
82    * @return handle to a ImageUrl object or an uninitialized handle.
83    */
84   static ImageUrl DownCast(BaseHandle handle);
85
86   /**
87    * Copy constructor
88    * @param[in] url The url to copy
89    */
90   ImageUrl(const ImageUrl& url);
91
92   /**
93    * Assignment operator
94    * @param[in] url The url to copy
95    */
96   ImageUrl& operator=(const ImageUrl& url);
97
98   /**
99    * @brief Move constructor.
100    * @param[in] rhs A reference to the moved handle
101    */
102   ImageUrl(ImageUrl&& rhs);
103
104   /**
105    * @brief Move assignment operator.
106    * @param[in] rhs A reference to the moved handle
107    * @return A reference to this handle
108    */
109   ImageUrl& operator=(ImageUrl&& rhs);
110
111   /**
112    * Get the url
113    * @return Returns url's string
114    */
115   const std::string& GetUrl() const;
116
117 public: // Not intended for application developers
118   /// @cond internal
119   /**
120    * @brief This constructor is used by New() methods.
121    *
122    * @param[in] internal A pointer to a newly allocated Dali resource.
123    */
124   explicit DALI_INTERNAL ImageUrl(Toolkit::Internal::ImageUrl* internal);
125   /// @endcond
126 };
127
128 } // namespace Toolkit
129
130 } // namespace Dali
131
132 #endif /* DALI_TOOLKIT_IMAGE_URL_H */