[dali_1.9.29] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / visuals / image-visual-properties.h
1 #ifndef DALI_TOOLKIT_IMAGE_VISUAL_PROPERTIES_H
2 #define DALI_TOOLKIT_IMAGE_VISUAL_PROPERTIES_H
3
4 /*
5  * Copyright (c) 2020 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
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 /**
29  * @addtogroup dali_toolkit_visuals
30  * @{
31  */
32
33 /**
34  * @brief ImageVisual is to render an image into the control's quad.
35  * @SINCE_1_1.45
36  */
37 namespace ImageVisual
38 {
39 /**
40  * @brief ImageVisual Property.
41  * @SINCE_1_1.45
42  */
43 namespace Property
44 {
45 /**
46  * @brief Enumeration for the instance of properties belonging to the ImageVisual.
47  * @SINCE_1_1.45
48  */
49 enum
50 {
51   /**
52    * @brief The URL of the image.
53    * @details Name "url", type Property::STRING or Property::ARRAY of Property::STRING.
54    * @note The array form is used for generating animated image visuals.
55    * @note The number of threads used for local and remote image loading can be controlled by the
56    *       environment variables DALI_TEXTURE_LOCAL_THREADS and DALI_TEXTURE_REMOTE_THREADS respectively.
57    *       The default values are 4 threads for local image loading and 8 threads for remote image loading.
58    * @SINCE_1_1.45
59    * @note Mandatory.
60    */
61   URL = VISUAL_PROPERTY_START_INDEX,
62
63   /**
64    * @brief Fitting options, used when resizing images to fit desired dimensions.
65    * @details Name "fittingMode", type Dali::FittingMode (Property::INTEGER) or Property::STRING.
66    * @SINCE_1_1.45
67    * @note Optional. If not supplied, default is FittingMode::SHRINK_TO_FIT.
68    * @note For Normal Quad images only.
69    * @see Dali::FittingMode
70    */
71   FITTING_MODE,
72
73   /**
74    * @brief Filtering options, used when resizing images to sample original pixels.
75    * @details Name "samplingMode", type Dali::SamplingMode (Property::INTEGER) or Property::STRING.
76    * @SINCE_1_1.45
77    * @note Optional. If not supplied, default is SamplingMode::BOX.
78    * @note For Normal Quad images only.
79    * @see Dali::SamplingMode
80    */
81   SAMPLING_MODE,
82
83   /**
84    * @brief The desired image width.
85    * @details Name "desiredWidth", type Property::INTEGER.
86    * @SINCE_1_1.45
87    * @note Optional. If not specified, the actual image width is used.
88    * @note For Normal Quad images only.
89    */
90   DESIRED_WIDTH,
91
92   /**
93    * @brief The desired image height.
94    * @details Name "desiredHeight", type Property::INTEGER.
95    * @SINCE_1_1.45
96    * @note Optional. If not specified, the actual image height is used.
97    * @note For Normal Quad images only.
98    */
99   DESIRED_HEIGHT,
100
101   /**
102    * @brief Whether to load the image synchronously.
103    * @details Name "synchronousLoading", type Property::BOOLEAN.
104    * @SINCE_1_1.45
105    * @note Optional. If not specified, the default is false, i.e. the image is loaded asynchronously.
106    * @note For Normal Quad images only.
107    */
108   SYNCHRONOUS_LOADING,
109
110   /**
111    * @brief If true, only draws the borders.
112    * @details Name "borderOnly", type Property::BOOLEAN.
113    * @SINCE_1_1.45
114    * @note Optional. If not specified, the default is false.
115    * @note For N-Patch images only.
116    */
117   BORDER_ONLY,
118
119   /**
120    * @brief The image area to be displayed.
121    * @details Name "pixelArea", type Property::VECTOR4.
122    *          It is a rectangular area.
123    *          The first two elements indicate the top-left position of the area, and the last two elements are the area width and height respectively.
124    * @SINCE_1_2.1
125    * @note Optional. If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
126    * @note For Normal Quad images only.
127    */
128   PIXEL_AREA,
129
130   /**
131    * @brief The wrap mode for u coordinate.
132    * @details Name "wrapModeU", type Dali::WrapMode::Type (Property::INTEGER) or Property::STRING.
133    *          It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.
134    * @SINCE_1_2.1
135    * @note Optional. If not specified, the default is CLAMP.
136    * @note For Normal QUAD image only.
137    */
138   WRAP_MODE_U,
139
140   /**
141    * @brief The wrap mode for v coordinate.
142    * @details Name "wrapModeV", type Dali::WrapMode::Type (Property::INTEGER) or Property::STRING.
143    *          it decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.
144    * @SINCE_1_2.1
145    * @note Optional. If not specified, the default is CLAMP.
146    * @note For Normal QUAD image only.
147    */
148   WRAP_MODE_V,
149
150   /**
151    * @brief The border of the image.
152    * @details Name "border", type Property::RECTANGLE or Property::VECTOR4.
153    *          The border of the image in the order: left, right, bottom, top.
154    * @SINCE_1_2.60
155    * @note Optional.
156    * @note For N-Patch images only.
157    */
158   BORDER,
159
160   /**
161    * @brief Whether to use the texture atlas
162    * @details Name "atlasing", type Property::BOOLEAN.
163    * @SINCE_1_2.60
164    * @note Optional. By default atlasing is off.
165    */
166   ATLASING,
167
168   /**
169    * @brief URL of a masking image
170    * @details Name "alphaMaskUrl", type Property::STRING, URL of image to apply as
171    * a mask after image loading. If set after the main URL has finished loading, this
172    * may necessitate a re-load of the main image. The alpha mask image will be scaled
173    * on load to match the size of the main image, then applied to the pixel data
174    * before uploading to GL.
175    * @SINCE_1_2.60
176    * @note Optional.
177    */
178   ALPHA_MASK_URL,
179
180   /**
181    * @brief Defines the batch size for pre-loading images in the AnimatedImageVisual
182    * @details Name "batchSize", type Property::INTEGER, number of images to pre-load
183    * before starting to play. Default value: 2
184    * @SINCE_1_2.60
185    * @note Optional.
186    * @note Minimum supported value is 2.
187    */
188   BATCH_SIZE,
189
190   /**
191    * @brief Defines the cache size for loading images in the AnimatedImageVisual
192    * @details Name "cacheSize", type Property::INTEGER, number of images to keep
193    * cached ahead during playback. Default value: 2
194    *
195    * @SINCE_1_2.60
196    * @note Optional.
197    * @note Minimum supported value is 2.
198    * @note, cacheSize should be >= batchSize.
199    * If it isn't, then the cache will automatically be changed to batchSize.
200    * @note, because of the defaults, it is expected that the application developer
201    * tune the batch and cache sizes to their particular use case.
202    */
203   CACHE_SIZE,
204
205   /**
206    * @brief The number of milliseconds between each frame in the AnimatedImageVisual
207    * @details Name "frameDelay", type Property::INTEGER, The number of milliseconds between each frame.
208    * @SINCE_1_2.60
209    * @note Optional.
210    * @note This is only used when multiple URLs are provided.
211    */
212   FRAME_DELAY,
213
214   /**
215    * @brief The scale factor to apply to the content image before masking
216    * @details Name "maskContentScale", type Property::FLOAT, The scale factor
217    * to apply to the content before masking. Note, scaled images are cropped to
218    * the same size as the alpha mask.
219    * @SINCE_1_2.60
220    * @note Optional.
221    */
222   MASK_CONTENT_SCALE,
223
224   /**
225    * @brief Whether to crop image to mask or scale mask to fit image
226    * @details Name "cropToMask", type Property::BOOLEAN, True if the image should
227    * be cropped to match the mask size, or false if the image should remain the same size.
228    * @SINCE_1_2.60
229    * @note Optional.
230    * @note If this is false, then the mask is scaled to fit the image before being applied.
231    */
232   CROP_TO_MASK,
233
234   /**
235    * @brief The policy to determine when an image should be loaded.
236    * @details Name "loadPolicy",  Type LoadPolicy::Type (Property::INTEGER)or Property::STRING.
237    * @SINCE_1_3_5
238    * @note Default LoadPolicy::ATTACHED
239    * @see LoadPolicy::Type
240    */
241
242   LOAD_POLICY,
243
244   /**
245    * @brief The policy to determine when an image should no longer be cached.
246    * @details Name "releasePolicy", Type ReleasePolicy::Type (Property::INTEGER) or Property::STRING
247    * @SINCE_1_3_5
248    * @note Default ReleasePolicy::DESTROYED
249    * @see ReleasePolicy::Type
250    */
251   RELEASE_POLICY,
252
253   /**
254    * @brief Determines if image orientation should be corrected so the image displays as it was intended.
255    * @details Name "orientationCorrection", Type Property::BOOLEAN, if true the image's orientation will be corrected.
256    * @SINCE_1_3_5
257    * @note Default true
258    */
259   ORIENTATION_CORRECTION,
260
261 };
262
263 } // namespace Property
264
265 /**
266  * @brief The policy determining if the image is loaded when the visual is staged or created.
267  * @SINCE_1_3_5
268  */
269 namespace LoadPolicy
270 {
271 /**
272  * @brief The available named elements that define the LoadPolicy.
273  * @SINCE_1_3_5
274  */
275 enum Type
276 {
277   IMMEDIATE = 0, ///< The image is loaded when the ImageVisual is created.
278   ATTACHED       ///< The image is loaded when the ImageVisual is attached to the stage.
279 };
280
281 } // namespace LoadPolicy
282
283 /**
284  * @brief The policy determining when a image is deleted from the cache in relation to the ImageVisual lifetime.
285  * @SINCE_1_3_5
286  * @note If the texture is being shared by another visual it persist if still required.
287  */
288 namespace ReleasePolicy
289 {
290 /**
291  * @brief The available named elements that define the ReleasePolicy.
292  * @SINCE_1_3_5
293  */
294 enum Type
295 {
296   DETACHED = 0, ///<  Image deleted from cache when ImageVisual detached from stage.
297   DESTROYED,    ///<  Image deleted from cache when ImageVisual destroyed.
298   NEVER         ///<  Image is never deleted, will survive the lifetime of the application.
299 };
300
301 } // namespace ReleasePolicy
302
303 } // namespace ImageVisual
304
305 /**
306  * @}
307  */
308
309 } // namespace Toolkit
310
311 } // namespace Dali
312
313 #endif // DALI_TOOLKIT_IMAGE_VISUAL_PROPERTIES_H