Tizen 2.4.0 rev3 SDK Public Release
[framework/graphics/dali.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 added to ImageViews.
42  *
43  * Image objects can be shared between ImageViews. This is practical if you have a visual element on screen
44  * which is repeatedly used. An example would be a button background image.
45  * The image resource is discarded when all ImageViews using the Image object are discarded.
46  * @since_tizen 2.4
47  * @note if a resource was shared between Image objects it exists until its last reference is gone.
48  *
49  * Image objects are responsible for the underlying resource's lifetime.
50  *
51  */
52 class DALI_IMPORT_API Image : public BaseHandle
53 {
54 public:
55   /**
56    * @brief Resource management options.
57    */
58
59   /**
60    * @brief ReleasePolicy controls the way images are deleted from memory.
61    * @since_tizen 2.4
62    * @remarks This is an experimental feature and might not be supported in the next release.
63    * We do recommend not to use it.
64    */
65   enum ReleasePolicy
66   {
67     UNUSED, ///< release resource once image is not in use anymore (eg. all actors using it become offstage). Reload when resource is required again. @since_tizen 2.4
68     NEVER   ///< keep image data for the lifetime of the object. (default) @since_tizen 2.4
69   };
70
71   /**
72    * @brief Type of signal for Image Uploaded.
73    * @since_tizen 2.4
74    */
75   typedef Signal< void (Image) > ImageSignalType;
76
77 public:
78
79   /**
80    * @brief Constructor which creates an empty Image handle.
81    *
82    * Use @ref Image::New to create an initialised handle.
83    * @since_tizen 2.4
84    */
85   Image();
86
87   /**
88    * @brief Destructor
89    *
90    * This is non-virtual since derived Handle types must not contain data or virtual methods.
91    * @since_tizen 2.4
92    */
93   ~Image();
94
95   /**
96    * @brief This copy constructor is required for (smart) pointer semantics.
97    *
98    * @since_tizen 2.4
99    * @param [in] handle A reference to the copied handle
100    */
101   Image(const Image& handle);
102
103   /**
104    * @brief This assignment operator is required for (smart) pointer semantics.
105    *
106    * @since_tizen 2.4
107    * @param [in] rhs  A reference to the copied handle
108    * @return A reference to this
109    */
110   Image& operator=(const Image& rhs);
111
112   /**
113    * @brief Downcast a handle to Image handle.
114    *
115    * If handle points to a Image object the
116    * downcast produces valid handle. If not the returned handle is left uninitialized.
117    * @since_tizen 2.4
118    * @param[in] handle Handle to an object
119    * @return Handle to a Image object or an uninitialized handle
120    */
121   static Image DownCast( BaseHandle handle );
122
123   /**
124    * @brief Return resource release policy.
125    *
126    * @since_tizen 2.4
127    * @remarks This is an experimental feature and might not be supported in the next release.
128    * We do recommend not to use it.
129    * @return Resource release policy
130    */
131   ReleasePolicy GetReleasePolicy() const;
132
133   /**
134    * @brief Returns the width of the image.
135    *
136    * Returns either the requested width or the actual loaded width if no specific size was requested.
137    *
138    * @since_tizen 2.4
139    * @return Width of the image in pixels.
140    */
141   unsigned int GetWidth() const;
142
143   /**
144    * @brief Returns the height of the image.
145    *
146    * Returns either the requested height or the actual loaded height if no specific size was requested.
147    *
148    * @since_tizen 2.4
149    * @return Height of the image in pixels.
150    */
151   unsigned int GetHeight() const;
152
153 public: // Signals
154
155   /**
156    * @brief This signal is emitted when the image data gets uploaded to GL.
157    *
158    * It Will be sent after an actor using the image is added to
159    * the stage, when such a staged image is reloaded, or when a staged
160    * BufferImage calls Update().
161    * @since_tizen 2.4
162    * @return A signal object to Connect() with.
163    */
164   ImageSignalType& UploadedSignal();
165
166 public: // Not intended for application developers
167
168   explicit DALI_INTERNAL Image(Internal::Image*);
169 };
170
171 /**
172  * @}
173  */
174 } // namespace Dali
175
176 #endif // __DALI_IMAGE_H__