[Tizen] 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 is a class for wrapping url that is get from external buffer.
38  * An instance of ImageUrl can be created from GenerateUrl().
39  * Application can get the ImageUrl at this time and use it by getting url from ImageUrl.
40  * When application does not use this anymore, the destructor of the ImageUrl is called.
41  * At this time, the buffer is deleted from the texture manager.
42  */
43 class DALI_TOOLKIT_API ImageUrl : public BaseHandle
44 {
45 public:
46   /**
47    * Default Constructor.
48    * Resulting URL is not valid
49    */
50   ImageUrl();
51
52   /**
53    * Destructor
54    */
55   ~ImageUrl();
56
57   /**
58    * @brief Create an initialized ImageUrl.
59    *
60    * @param[in] texture The texture url is got from external buffer.
61    * @return A handle to a newly allocated Dali resource.
62    */
63   static ImageUrl New(Texture& texture);
64
65   /**
66    * @brief Create an initialized ImageUrl.
67    *
68    * @param[in] encodedImageBuffer The encoded image buffer url is got from external buffer.
69    * @return A handle to a newly allocated Dali resource.
70    */
71   static ImageUrl New(const EncodedImageBuffer& encodedImageBuffer);
72
73   /**
74    * @brief Downcast an Object handle to ImageUrl handle.
75    *
76    * If handle points to a ImageUrl object the downcast produces valid
77    * handle. If not the returned handle is left uninitialized.
78    *
79    * @param[in] handle to An object.
80    * @return handle to a ImageUrl object or an uninitialized handle.
81    */
82   static ImageUrl DownCast(BaseHandle handle);
83
84   /**
85    * Copy constructor
86    * @param[in] url The url to copy
87    */
88   ImageUrl(const ImageUrl& url);
89
90   /**
91    * Assignment operator
92    * @param[in] url The url to copy
93    */
94   ImageUrl& operator=(const ImageUrl& url);
95
96   /**
97    * @brief Move constructor.
98    * @param[in] rhs A reference to the moved handle
99    */
100   ImageUrl(ImageUrl&& rhs);
101
102   /**
103    * @brief Move assignment operator.
104    * @param[in] rhs A reference to the moved handle
105    * @return A reference to this handle
106    */
107   ImageUrl& operator=(ImageUrl&& rhs);
108
109   /**
110    * Get the url
111    * @return Returns url's string
112    */
113   const std::string& GetUrl() const;
114
115 public: // Not intended for application developers
116   /// @cond internal
117   /**
118    * @brief This constructor is used by New() methods.
119    *
120    * @param[in] internal A pointer to a newly allocated Dali resource.
121    */
122   explicit DALI_INTERNAL ImageUrl(Toolkit::Internal::ImageUrl* internal);
123   /// @endcond
124 };
125
126 } // namespace Toolkit
127
128 } // namespace Dali
129
130 #endif /* DALI_TOOLKIT_IMAGE_URL_H */