1 #ifndef DALI_INTERNAL_CAPTURE_H
2 #define DALI_INTERNAL_CAPTURE_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali/public-api/object/base-object.h>
26 #include <dali/public-api/render-tasks/render-task.h>
27 #include <dali/public-api/rendering/texture.h>
28 #include <dali/public-api/rendering/frame-buffer.h>
31 #include <dali/public-api/dali-adaptor-common.h>
32 #include <dali/public-api/capture/capture.h>
33 #include <dali/public-api/adaptor-framework/native-image-source.h>
34 #include <dali/public-api/adaptor-framework/timer.h>
46 typedef IntrusivePtr<Capture> CapturePtr;
48 class Capture : public BaseObject, public ConnectionTracker
56 Capture( Dali::CameraActor cameraActor );
59 * @copydoc Dali::Capture::New
61 static CapturePtr New();
64 * @copydoc Dali::Capture::New
66 static CapturePtr New( Dali::CameraActor cameraActor );
69 * @copydoc Dali::Capture::Start
71 void Start( Dali::Actor source, const Dali::Vector2& size, const std::string &path, const Dali::Vector4& clearColor );
74 * @copydoc Dali::Capture::FinishedSignal
76 Dali::Capture::CaptureFinishedSignalType& FinishedSignal();
81 * @brief A reference counted object may only be deleted by calling Unreference()
87 * @brief Create native image source.
89 void CreateNativeImageSource( const Dali::Vector2& size );
92 * @brief Delete native image source.
94 void DeleteNativeImageSource();
97 * @brief Query whether native image source is created or not.
99 * @return True is native image source is created.
101 bool IsNativeImageSourceCreated();
104 * @brief Create frame buffer.
106 void CreateFrameBuffer();
109 * @brief Delete frame buffer.
111 void DeleteFrameBuffer();
114 * @brief Query whether frame buffer is created or not.
116 * @return True is frame buffer is created.
118 bool IsFrameBufferCreated();
121 * @brief Setup render task.
123 * @param[in] source is captured.
124 * @param[in] clearColor background color
126 void SetupRenderTask( Dali::Actor source, const Dali::Vector4& clearColor );
129 * @brief Unset render task.
131 void UnsetRenderTask();
134 * @brief Query whether render task is setup or not.
136 * @return True is render task is setup.
138 bool IsRenderTaskSetup();
141 * @brief Setup resources for capture.
143 * @param[in] size is surface size.
144 * @param[in] clearColor is clear color of surface.
145 * @param[in] source is captured.
147 void SetupResources( const Dali::Vector2& size, const Dali::Vector4& clearColor, Dali::Actor source );
150 * @brief Unset resources for capture.
152 void UnsetResources();
155 * @brief Callback when render is finished.
157 * @param[in] task is used for capture.
159 void OnRenderFinished( Dali::RenderTask& task );
162 * @brief Callback when timer is finished.
164 * @return True is timer start again.
169 * @brief Save framebuffer.
171 * @return True is success to save, false is fail.
178 Capture( const Capture& );
181 Capture& operator=( const Capture& rhs );
184 Dali::Texture mNativeTexture;
185 Dali::FrameBuffer mFrameBuffer;
186 Dali::RenderTask mRenderTask;
189 Dali::CameraActor mCameraActor;
190 Dali::Timer mTimer; ///< For timeout.
191 Dali::Capture::CaptureFinishedSignalType mFinishedSignal;
193 Dali::NativeImageSourcePtr mNativeImageSourcePtr; ///< pointer to surface image
196 } // End of namespace Adaptor
197 } // End of namespace Internal
199 // Helpers for public-api forwarding methods
201 inline Internal::Adaptor::Capture& GetImpl( Dali::Capture& captureWorker)
203 DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
205 BaseObject& handle = captureWorker.GetBaseObject();
207 return static_cast< Internal::Adaptor::Capture& >( handle );
210 inline const Internal::Adaptor::Capture& GetImpl( const Dali::Capture& captureWorker )
212 DALI_ASSERT_ALWAYS( captureWorker && "Capture handle is empty" );
214 const BaseObject& handle = captureWorker.GetBaseObject();
216 return static_cast< const Internal::Adaptor::Capture& >( handle );
219 } // End of namespace Dali
221 #endif // DALI_INTERNAL_CAPTURE_H