Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[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) 2018 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 #include <cstdint> // uint32_t
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/object/base-handle.h>
27 #include <dali/public-api/signals/dali-signal.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_core_images
33  * @{
34  */
35
36 namespace Internal DALI_INTERNAL
37 {
38 class Image;
39 }
40
41 /**
42  * @DEPRECATED_1_2.41
43  *
44  * @brief An Image object represents an image resource that can be used for rendering.
45  *
46  * Image objects can be shared between Actors. This is practical if you have a visual element on screen
47  * which is repeatedly used.
48  *
49  * The image resource is released as soon as the last Image handle is released.
50  * @SINCE_1_0.0
51  * @note If a resource was shared between Image objects it exists until its last reference is gone.
52  *
53  * Image objects are responsible for the underlying resource's lifetime.
54  *
55  * Signals
56  * | %Signal Name           | Method                       |
57  * |------------------------|------------------------------|
58  * | uploaded               | @ref UploadedSignal()        |
59  * @SINCE_1_0.0
60  */
61 class DALI_CORE_API Image : public BaseHandle
62 {
63 public:
64
65   /**
66    * @DEPRECATED_1_2.41
67    *
68    * @brief Type of signal for Image Uploaded.
69    * @SINCE_1_0.0
70    */
71   typedef Signal< void (Image) > ImageSignalType;
72
73 public:
74
75   /**
76    * @DEPRECATED_1_2.41
77    *
78    * @brief Constructor which creates an empty Image handle.
79    *
80    * This class has no New method.
81    * Use the appropriate New method of its subclasses to create an initialized handle.
82    * (Dali::BufferImage::New(), Dali::EncodedBufferImage::New(), Dali::FrameBufferImage::New(),
83    * Dali::NativeImage::New(), Dali::ResourceImage::New()).
84    * @SINCE_1_0.0
85    */
86   Image() DALI_DEPRECATED_API;
87
88   /**
89    * @DEPRECATED_1_2.41
90    *
91    * @brief Destructor.
92    *
93    * This is non-virtual since derived Handle types must not contain data or virtual methods.
94    * @SINCE_1_0.0
95    */
96   ~Image() DALI_DEPRECATED_API;
97
98   /**
99    * @DEPRECATED_1_2.41
100    *
101    * @brief This copy constructor is required for (smart) pointer semantics.
102    *
103    * @SINCE_1_0.0
104    * @param[in] handle A reference to the copied handle
105    */
106   Image(const Image& handle) DALI_DEPRECATED_API;
107
108   /**
109    * @DEPRECATED_1_2.41
110    *
111    * @brief This assignment operator is required for (smart) pointer semantics.
112    *
113    * @SINCE_1_0.0
114    * @param[in] rhs A reference to the copied handle
115    * @return A reference to this
116    */
117   Image& operator=(const Image& rhs) DALI_DEPRECATED_API;
118
119   /**
120    * @DEPRECATED_1_2.41
121    *
122    * @brief Downcasts a handle to Image handle.
123    *
124    * If handle points to a Image object, the
125    * downcast produces valid handle. If not, the returned handle is left uninitialized.
126    * @SINCE_1_0.0
127    * @param[in] handle Handle to an object
128    * @return Handle to a Image object or an uninitialized handle
129    */
130   static Image DownCast( BaseHandle handle ) DALI_DEPRECATED_API;
131
132   /**
133    * @DEPRECATED_1_2.41
134    *
135    * @brief Returns the width of the image.
136    *
137    * Returns either the requested width or the actual loaded width if no specific size was requested.
138    *
139    * @SINCE_1_0.0
140    * @return Width of the image in pixels
141    */
142   uint32_t GetWidth() const DALI_DEPRECATED_API;
143
144   /**
145    * @DEPRECATED_1_2.41
146    *
147    * @brief Returns the height of the image.
148    *
149    * Returns either the requested height or the actual loaded height if no specific size was requested.
150    *
151    * @SINCE_1_0.0
152    * @return Height of the image in pixels
153    */
154   uint32_t GetHeight() const DALI_DEPRECATED_API;
155
156 public: // Signals
157
158   /**
159    * @DEPRECATED_1_2.41
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    * BufferImage calls Update().
166    * @SINCE_1_0.0
167    * @return A signal object to Connect() with
168    */
169   ImageSignalType& UploadedSignal() DALI_DEPRECATED_API;
170
171 public: // Not intended for application developers
172
173   explicit DALI_INTERNAL Image(Internal::Image*);
174 };
175
176 /**
177  * @}
178  */
179 } // namespace Dali
180
181 #endif // __DALI_IMAGE_H__