Merge "Divide Render() into small apis" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / image-loader / async-image-loader-devel.h
1 #ifndef DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_H
2 #define DALI_TOOLKIT_DEVEL_API_IMAGE_LOADER_ASYNC_IMAGE_LOADER_DEVEL_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 // EXTERNAL HEADER
21 #include <dali/public-api/signals/dali-signal.h>
22 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
23 #include <dali/devel-api/adaptor-framework/animated-image-loading.h>
24
25 // INTERNAL HEADER
26 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
27
28 namespace Dali
29 {
30 namespace Toolkit
31 {
32 namespace DevelAsyncImageLoader
33 {
34
35 typedef Signal< void ( uint32_t, Devel::PixelBuffer ) > PixelBufferLoadedSignalType;
36
37 /**
38  * @brief Whether to multiply alpha into color channels on load
39  */
40 enum class PreMultiplyOnLoad
41 {
42   OFF = 0, ///< Don't modify the image
43   ON           ///< Multiply alpha into color channels on load
44 };
45
46 /**
47  * @brief Starts an animated image loading task.
48  * @REMARK_INTERNET
49  * @REMARK_STORAGE
50  * @param[in] asyncImageLoader The ayncImageLoader
51  * @param[in] animatedImageLoading The AnimatedImageLoading to load animated image
52  * @param[in] frameIndex The frame index of a frame to be loaded frame
53  * @return The loading task id
54  */
55 DALI_TOOLKIT_API uint32_t LoadAnimatedImage( AsyncImageLoader asyncImageLoader,
56                                              Dali::AnimatedImageLoading animatedImageLoading,
57                                              uint32_t frameIndex );
58
59 /**
60  * @brief Starts an image loading task.
61  * @REMARK_INTERNET
62  * @REMARK_STORAGE
63  * @param[in] asyncImageLoader The ayncImageLoader
64  * @param[in] url The URL of the image file to load
65  * @param[in] dimensions The width and height to fit the loaded image to
66  * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
67  * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
68  * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
69  * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask.
70  * @return The loading task id
71  */
72 DALI_TOOLKIT_API uint32_t Load( AsyncImageLoader asyncImageLoader,
73                                 const std::string& url,
74                                 ImageDimensions dimensions,
75                                 FittingMode::Type fittingMode,
76                                 SamplingMode::Type samplingMode,
77                                 bool orientationCorrection,
78                                 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
79
80 /**
81  * @brief Starts an mask applying task.
82  * @REMARK_INTERNET
83  * @REMARK_STORAGE
84  * @param[in] asyncImageLoader The ayncImageLoader
85  * @param[in] pixelBuffer Pointer to raw pixel data to be masked
86  * @param[in] maskPixelBuffer Pointer to raw masking data
87  * @param[in] contentScale The factor to scale the content
88  * @param[in] cropToMask Whether to crop the content to the mask size
89  * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha.
90  * @return The masking task id
91  */
92 DALI_TOOLKIT_API uint32_t ApplyMask( AsyncImageLoader asyncImageLoader,
93                                      Devel::PixelBuffer pixelBuffer,
94                                      Devel::PixelBuffer maskPixelBuffer,
95                                      float contentScale,
96                                      bool cropToMask,
97                                      DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
98
99 /**
100  * Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
101  * @note Connecting to this signal prevents the emission of the ImageLoadedSignal.
102  */
103 DALI_TOOLKIT_API PixelBufferLoadedSignalType&  PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader );
104
105 }
106 } // Toolkit
107 } // Dali
108
109 #endif