[dali_1.1.19] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / images / image.h
1 #ifndef __DALI_IMAGE_H__
2 #define __DALI_IMAGE_H__
3
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/signals/dali-signal.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_core_images
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37 class Image;
38 }
39
40 /**
41  * @brief An Image object represents an image resource that can be used for rendering
42  *
43  * Image objects can be shared between Actors. This is practical if you have a visual element on screen
44  * which is repeatedly used.
45  *
46  * Image objects are responsible for the underlying resource's lifetime.
47  * Note: if a resource was shared between Image objects it exists until its last reference is gone.
48  *
49  * Signals
50  * | %Signal Name           | Method                       |
51  * |------------------------|------------------------------|
52  * | uploaded               | @ref UploadedSignal()        |
53  * @SINCE_1_0.0
54  */
55 class DALI_IMPORT_API Image : public BaseHandle
56 {
57 public:
58
59   /**
60    * @DEPRECATED_1_1.3. Image resource is released as soon as last handle is released.
61    * @brief ReleasePolicy controls the way images are deleted from memory.
62    * @SINCE_1_0.0
63    */
64   enum ReleasePolicy
65   {
66     UNUSED, ///< release resource once image is not in use anymore (eg. all actors using it become offstage). Reload when resource is required again. @SINCE_1_0.0
67     NEVER   ///< keep image data for the lifetime of the object. (default) @SINCE_1_0.0
68   };
69
70   /**
71    * @brief Type of signal for Image Uploaded.
72    * @SINCE_1_0.0
73    */
74   typedef Signal< void (Image) > ImageSignalType;
75
76 public:
77
78   /**
79    * @brief Constructor which creates an empty Image handle.
80    *
81    * Use Image::New(...) to create an initialised handle.
82    * @SINCE_1_0.0
83    */
84   Image();
85
86   /**
87    * @brief Destructor
88    *
89    * This is non-virtual since derived Handle types must not contain data or virtual methods.
90    * @SINCE_1_0.0
91    */
92   ~Image();
93
94   /**
95    * @brief This copy constructor is required for (smart) pointer semantics.
96    *
97    * @SINCE_1_0.0
98    * @param [in] handle A reference to the copied handle
99    */
100   Image(const Image& handle);
101
102   /**
103    * @brief This assignment operator is required for (smart) pointer semantics.
104    *
105    * @SINCE_1_0.0
106    * @param [in] rhs  A reference to the copied handle
107    * @return A reference to this
108    */
109   Image& operator=(const Image& rhs);
110
111   /**
112    * @brief Downcast an Object handle to Image handle.
113    *
114    * If handle points to a Image object the
115    * downcast produces valid handle. If not the returned handle is left uninitialized.
116    * @SINCE_1_0.0
117    * @param[in] handle to An object
118    * @return handle to a Image object or an uninitialized handle
119    */
120   static Image DownCast( BaseHandle handle );
121
122   /**
123    * @DEPRECATED_1_1.3
124    *
125    * @brief Return resource release policy.
126    *
127    * @SINCE_1_0.0
128    * @return resource release policy
129    */
130   ReleasePolicy GetReleasePolicy() const;
131
132   /**
133    * @brief Returns the width of the image.
134    *
135    * Returns either the requested width or the actual loaded width if no specific size was requested.
136    *
137    * @SINCE_1_0.0
138    * @return width of the image in pixels.
139    */
140   unsigned int GetWidth() const;
141
142   /**
143    * @brief Returns the height of the image.
144    *
145    * Returns either the requested height or the actual loaded height if no specific size was requested.
146    *
147    * @SINCE_1_0.0
148    * @return height of the image in pixels.
149    */
150   unsigned int GetHeight() const;
151
152 public: // Signals
153
154   /**
155    * @brief This signal is emitted when the image data gets uploaded to GL.
156    *
157    * It Will be sent after an actor using the image is added to
158    * the stage, when such a staged image is reloaded, or when a staged
159    * BufferImage calls Update().
160    * @SINCE_1_0.0
161    * @return A signal object to Connect() with.
162    */
163   ImageSignalType& UploadedSignal();
164
165 public: // Not intended for application developers
166
167   explicit DALI_INTERNAL Image(Internal::Image*);
168 };
169
170 /**
171  * @}
172  */
173 } // namespace Dali
174
175 #endif // __DALI_IMAGE_H__