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