Revert "[Tizen] Add codes for Dali Windows Backend"
[platform/core/uifw/dali-adaptor.git] / dali / public-api / capture / capture.h
1 #ifndef DALI_CAPTURE_H
2 #define DALI_CAPTURE_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 HEADERS
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/signals/dali-signal.h>
24 #include <dali/public-api/actors/camera-actor.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31
32 /**
33  * @addtogroup dali_adaptor_framework
34  * @{
35  */
36
37 namespace Internal DALI_INTERNAL
38 {
39 namespace Adaptor
40 {
41 class Capture;
42 }
43 }
44
45 /**
46  * @brief Capture snapshots the current scene and save as a file.
47  *
48  * @SINCE_1_3_4
49  *
50  * Applications should follow the example below to create capture :
51  *
52  * @code
53  * Capture capture = Capture::New();
54  * @endcode
55  *
56  * If required, you can also connect class member function to a signal :
57  *
58  * @code
59  * capture.FinishedSignal().Connect(this, &CaptureSceneExample::OnCaptureFinished);
60  * @endcode
61  *
62  * At the connected class member function, you can know whether capture finish state.
63  *
64  * @code
65  * void CaptureSceneExample::OnCaptureFinished( Capture capture, Capture::FinishState state )
66  * {
67  *   if ( state == Capture::FinishState::SUCCEEDED )
68  *   {
69  *     // Do something
70  *   }
71  *   else
72  *   {
73  *     // Do something
74  *   }
75  * }
76  * @endcode
77  */
78 class DALI_ADAPTOR_API Capture : public BaseHandle
79 {
80
81 public:
82
83   /**
84    * @brief The enumerations used for checking capture success
85    * @SINCE_1_3_4
86    */
87   enum class FinishState
88   {
89     SUCCEEDED, ///< Succeeded in saving the result after capture
90     FAILED     ///< Failed to capture by time out or to save the result
91   };
92
93   /**
94    * @brief Typedef for finished signals sent by this class.
95    *
96    * @SINCE_1_3_4
97    */
98   typedef Signal< void ( Capture, Capture::FinishState ) > CaptureFinishedSignalType;
99
100   /**
101    * @brief Create an uninitialized Capture; this can be initialized with Actor::New().
102    *
103    * @SINCE_1_3_4
104    *
105    * Calling member functions with an uninitialized Dali::Object is not allowed.
106    */
107   Capture();
108
109   /**
110    * @brief Create an initialized Capture.
111    *
112    * @SINCE_1_3_4
113    *
114    * @return A handle to a newly allocated Dali resource.
115    * @note Projection mode of default cameraActor is Dali::Camera::PERSPECTIVE_PROJECTION
116    */
117   static Capture New();
118
119   /**
120    * @brief Create an initialized Capture.
121    *
122    * @SINCE_1_3_4
123    *
124    * @param[in] cameraActor An initialized CameraActor.
125    * @return A handle to a newly allocated Dali resource.
126    */
127   static Capture New( Dali::CameraActor cameraActor );
128
129   /**
130    * @brief Downcast an Object handle to Capture handle.
131    *
132    * @SINCE_1_3_4
133    *
134    * If handle points to a Capture object the downcast produces valid
135    * handle. If not the returned handle is left uninitialized.
136    *
137    * @param[in] handle to An object.
138    * @return handle to a Capture object or an uninitialized handle.
139    */
140   static Capture DownCast( BaseHandle handle );
141
142   /**
143    * @brief Dali::Actor is intended as a base class.
144    *
145    * @SINCE_1_3_4
146    *
147    * This is non-virtual since derived Handle types must not contain data or virtual methods.
148    */
149   ~Capture();
150
151   /**
152    * @brief This copy constructor is required for (smart) pointer semantics.
153    *
154    * @SINCE_1_3_4
155    *
156    * @param[in] copy A reference to the copied handle.
157    */
158   Capture( const Capture& copy );
159
160   /**
161    * @brief This assignment operator is required for (smart) pointer semantics.
162    *
163    * @SINCE_1_3_4
164    *
165    * @param[in] rhs  A reference to the copied handle.
166    * @return A reference to this.
167    */
168   Capture& operator=( const Capture& rhs );
169
170   /**
171    * @brief Start capture and save the image as a file.
172    *
173    * @SINCE_1_3_4
174    *
175    * @param[in] source source actor to be used for capture.
176    * @param[in] size captured size.
177    * @param[in] path image file path to be saved as a file.
178    * @param[in] clearColor background color of captured scene
179    */
180   void Start( Actor source, const Vector2& size, const std::string &path, const Vector4& clearColor );
181
182   /**
183    * @brief Start capture and save the image as a file.
184    *
185    * @SINCE_1_3_4
186    *
187    * @param[in] source source actor to be used for capture.
188    * @param[in] size captured size.
189    * @param[in] path image file path to be saved as a file.
190    * @note Clear color is transparent.
191    */
192   void Start( Actor source, const Vector2& size, const std::string &path );
193
194   /**
195    * @brief Get finished signal.
196    *
197    * @SINCE_1_3_4
198    *
199    * @return finished signal instance.
200    */
201   CaptureFinishedSignalType& FinishedSignal();
202
203 public: // Not intended for application developers
204   /// @cond internal
205   /**
206    * @brief This constructor is used by New() methods.
207    *
208    * @SINCE_1_3_4
209    *
210    * @param[in] internal A pointer to a newly allocated Dali resource.
211    */
212   explicit DALI_INTERNAL Capture( Internal::Adaptor::Capture* internal );
213   /// @endcond
214 };
215
216 /**
217  * @}
218  */
219
220 } // namespace Dali
221
222 #endif // DALI_CAPTURE_H